Chore: Upgrade to Angular v18
Chore: Upgrade to Python 3.12 Chore: Upgrade to psycopg3
This commit is contained in:
22
bookie/src/app/sales/bills/bill.resolver.ts
Normal file
22
bookie/src/app/sales/bills/bill.resolver.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Bill } from './bill';
|
||||
import { VoucherService } from './voucher.service';
|
||||
|
||||
export const billResolver: ResolveFn<Bill> = (route) => {
|
||||
const tableId = route.queryParamMap.get('table');
|
||||
const guestId = route.queryParamMap.get('guest');
|
||||
const voucherId = route.queryParamMap.get('voucher');
|
||||
const billId = route.queryParamMap.get('bill');
|
||||
if (billId !== null) {
|
||||
return inject(VoucherService).getFromBill(billId);
|
||||
}
|
||||
if (tableId !== null) {
|
||||
return inject(VoucherService).getFromTable(tableId as string, voucherId, guestId);
|
||||
}
|
||||
if (voucherId !== null) {
|
||||
return inject(VoucherService).getFromId(voucherId);
|
||||
}
|
||||
throw new Error('Unable to get bill');
|
||||
};
|
||||
Reference in New Issue
Block a user