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