mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 03:32:52 +00:00
feat: show availability in offers
This commit is contained in:
@@ -45,11 +45,11 @@
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
<ion-grid *ngIf="offer.prices">
|
||||
<ion-grid *ngIf="offer.prices && offer.availability !== 'out of stock'">
|
||||
<ion-row *ngFor="let group of objectKeys(offer.prices)">
|
||||
<ion-col *ngIf="group !== 'default'">{{
|
||||
'data.detail.offers.' + group | translate
|
||||
}}</ion-col>
|
||||
<ion-col *ngIf="group !== 'default'"
|
||||
>{{ 'data.detail.offers.' + group | translate }}
|
||||
</ion-col>
|
||||
<ion-col *ngIf="group !== 'default'" width-20 text-right>
|
||||
<p>
|
||||
{{
|
||||
@@ -59,6 +59,18 @@
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
<ion-grid *ngIf="offer.availability === 'out of stock'">
|
||||
<ion-row>
|
||||
<ion-col></ion-col>
|
||||
<ion-col width-20 text-right>
|
||||
<ion-text color="danger">
|
||||
<p>
|
||||
{{ 'data.detail.offers.sold_out' | translate }}
|
||||
</p>
|
||||
</ion-text>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</div>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
@@ -35,15 +35,20 @@ export class OffersInListComponent {
|
||||
) {
|
||||
this._offers = it;
|
||||
this.price = it[0].prices?.default;
|
||||
|
||||
this.settingsProvider.getSetting('profile', 'group').then(group => {
|
||||
this.price =
|
||||
it[0].prices?.[(group.value as string).replace(/s$/, '') as never];
|
||||
});
|
||||
|
||||
const availabilities = new Set(it.map(offer => offer.availability));
|
||||
this.soldOut =
|
||||
availabilities.has('out of stock') && availabilities.size === 1;
|
||||
}
|
||||
|
||||
price?: number;
|
||||
|
||||
soldOut: boolean;
|
||||
|
||||
_offers: Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;
|
||||
|
||||
constructor(readonly settingsProvider: SettingsProvider) {}
|
||||
|
||||
@@ -14,10 +14,17 @@
|
||||
-->
|
||||
|
||||
<div>
|
||||
<h2 *ngIf="price">
|
||||
{{ price | currency: 'EUR':'symbol':undefined:'de' }}
|
||||
</h2>
|
||||
<p *ngIf="_offers[0].inPlace">
|
||||
<ion-text *ngIf="price && !soldOut">
|
||||
<h2>
|
||||
{{ price | currency: 'EUR':'symbol':undefined:'de' }}
|
||||
</h2>
|
||||
</ion-text>
|
||||
<ion-text *ngIf="soldOut" color="danger">
|
||||
<h2>
|
||||
{{ 'data.detail.offers.sold_out' | translate }}
|
||||
</h2>
|
||||
</ion-text>
|
||||
<p *ngIf="_offers[0].inPlace && !soldOut">
|
||||
<ion-icon name="pin_drop"></ion-icon>{{ _offers[0].inPlace.name
|
||||
}}<span *ngIf="_offers.length > 1">...</span>
|
||||
</p>
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
import moment from 'moment';
|
||||
import {DataProvider} from '../../../../data.provider';
|
||||
import {mapValues} from '../../../../../../_helpers/collections/map-values';
|
||||
import {SettingsProvider} from '../../../../../settings/settings.provider';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -32,7 +33,10 @@ import {mapValues} from '../../../../../../_helpers/collections/map-values';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PlaceMensaService {
|
||||
constructor(private dataProvider: DataProvider) {}
|
||||
constructor(
|
||||
private dataProvider: DataProvider,
|
||||
readonly settingsProvider: SettingsProvider,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Fetches all dishes for this building
|
||||
@@ -43,6 +47,10 @@ export class PlaceMensaService {
|
||||
place: SCPlace,
|
||||
days: number,
|
||||
): Promise<Record<SCISO8601Date, SCDish[]>> {
|
||||
const priceGroup = await this.settingsProvider.getSetting(
|
||||
'profile',
|
||||
'group',
|
||||
);
|
||||
const request = mapValues<
|
||||
Record<SCISO8601Date, SCISO8601Date>,
|
||||
SCSearchQuery
|
||||
@@ -85,6 +93,18 @@ export class PlaceMensaService {
|
||||
},
|
||||
type: 'boolean',
|
||||
},
|
||||
sort: [
|
||||
{
|
||||
arguments: {
|
||||
field: `offers.prices.${(priceGroup.value as string).replace(
|
||||
/s$/,
|
||||
'',
|
||||
)}`,
|
||||
},
|
||||
order: 'desc',
|
||||
type: 'generic',
|
||||
},
|
||||
],
|
||||
size: 1000,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -122,7 +122,8 @@
|
||||
"default": "Standard",
|
||||
"employee": "Angestellte",
|
||||
"guest": "Gäste",
|
||||
"student": "Studuierende"
|
||||
"student": "Studierende",
|
||||
"sold_out": "Ausverkauft!"
|
||||
}
|
||||
},
|
||||
"chips": {
|
||||
|
||||
@@ -122,7 +122,8 @@
|
||||
"default": "Default",
|
||||
"employee": "Employees",
|
||||
"guest": "Guests",
|
||||
"student": "Students"
|
||||
"student": "Students",
|
||||
"sold_out": "Sold Out!"
|
||||
}
|
||||
},
|
||||
"chips": {
|
||||
|
||||
Reference in New Issue
Block a user