Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -1,37 +1,77 @@
|
||||
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple [routerLink]="['menu-categories']"
|
||||
queryParamsHandling="preserve">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
[routerLink]="['menu-categories']"
|
||||
queryParamsHandling="preserve"
|
||||
>
|
||||
<h3 class="item-name">Add Product</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="discount()"
|
||||
[class.disabled]="!discountAllowed()">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
(click)="discount()"
|
||||
[class.disabled]="!discountAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Discount</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="printKot()"
|
||||
[class.disabled]="!printKotAllowed()">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
(click)="printKot()"
|
||||
[class.disabled]="!printKotAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Print KOT</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="printBill()"
|
||||
[class.disabled]="!printBillAllowed()">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
(click)="printBill()"
|
||||
[class.disabled]="!printBillAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Print Bill</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button warn" matRipple [routerLink]="['../../tables']">
|
||||
<h3 class="item-name">Back to Tables</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="receivePayment()"
|
||||
[class.disabled]="!receivePaymentAllowed()">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
(click)="receivePayment()"
|
||||
[class.disabled]="!receivePaymentAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Receive Payment</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="moveTable()"
|
||||
[class.disabled]="!moveTableAllowed()">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
(click)="moveTable()"
|
||||
[class.disabled]="!moveTableAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Move Table</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="voidBill()"
|
||||
[class.disabled]="!voidBillAllowed()">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
(click)="voidBill()"
|
||||
[class.disabled]="!voidBillAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Void Bill</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="splitBill()"
|
||||
[class.disabled]="!splitBillAllowed()">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
(click)="splitBill()"
|
||||
[class.disabled]="!splitBillAllowed()"
|
||||
>
|
||||
<h3 class="item-name">Split Bill</h3>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {SalesHomeComponent} from './sales-home.component';
|
||||
import { SalesHomeComponent } from './sales-home.component';
|
||||
|
||||
describe('SalesHomeComponent', () => {
|
||||
let component: SalesHomeComponent;
|
||||
@ -8,9 +8,8 @@ describe('SalesHomeComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SalesHomeComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [SalesHomeComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Component } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { map, switchMap, tap } from 'rxjs/operators';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Observable, of as observableOf, throwError } from 'rxjs';
|
||||
import { BillService } from '../bill.service';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { DiscountComponent } from '../discount/discount.component';
|
||||
import { SaleCategoryService } from '../../sale-category/sale-category.service';
|
||||
import { BillTypeComponent } from '../bill-type/bill-type.component';
|
||||
import { PrintType } from '../bills/bill';
|
||||
import { map, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
import { AuthService } from '../../auth/auth.service';
|
||||
import { ReceivePaymentComponent } from '../receive-payment/receive-payment.component';
|
||||
import { TableService } from '../../tables/table.service';
|
||||
import { Table } from '../../core/table';
|
||||
import { TablesDialogComponent } from '../tables-dialog/tables-dialog.component';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { SaleCategoryService } from '../../sale-category/sale-category.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { TableService } from '../../tables/table.service';
|
||||
import { BillTypeComponent } from '../bill-type/bill-type.component';
|
||||
import { BillService } from '../bill.service';
|
||||
import { PrintType } from '../bills/print-type';
|
||||
import { DiscountComponent } from '../discount/discount.component';
|
||||
import { ReasonComponent } from '../reason/reason.component';
|
||||
import { ReceivePaymentComponent } from '../receive-payment/receive-payment.component';
|
||||
import { TablesDialogComponent } from '../tables-dialog/tables-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sales-home',
|
||||
templateUrl: './sales-home.component.html',
|
||||
styleUrls: ['./sales-home.component.css']
|
||||
styleUrls: ['./sales-home.component.css'],
|
||||
})
|
||||
export class SalesHomeComponent implements OnInit {
|
||||
|
||||
export class SalesHomeComponent {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
@ -32,11 +32,8 @@ export class SalesHomeComponent implements OnInit {
|
||||
private toaster: ToasterService,
|
||||
private mcSer: SaleCategoryService,
|
||||
private tSer: TableService,
|
||||
private bs: BillService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
private bs: BillService,
|
||||
) {}
|
||||
|
||||
printKotAllowed(): boolean {
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('print-kot') === -1) {
|
||||
@ -62,7 +59,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (this.route.snapshot.queryParamMap.has('guest')) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get('guest');
|
||||
}
|
||||
this.bs.printKot(guestBookId).subscribe(x => {
|
||||
this.bs.printKot(guestBookId).subscribe(() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
});
|
||||
@ -72,57 +69,61 @@ export class SalesHomeComponent implements OnInit {
|
||||
return this.auth.user && this.auth.user.perms.indexOf('discount') !== -1;
|
||||
}
|
||||
|
||||
showDiscount(): Observable<boolean | { id: string, name: string, discount: number }[]> {
|
||||
showDiscount(): Observable<boolean | { id: string; name: string; discount: number }[]> {
|
||||
if (this.discountAllowed()) {
|
||||
const dialogRef = this.dialog.open(DiscountComponent, {
|
||||
// width: '750px',
|
||||
data: this.mcSer.listForDiscount()
|
||||
data: this.mcSer.listForDiscount(),
|
||||
});
|
||||
return dialogRef.afterClosed();
|
||||
} else {
|
||||
return observableOf(false);
|
||||
}
|
||||
return observableOf(false);
|
||||
}
|
||||
|
||||
discount(): void {
|
||||
this.showDiscount().subscribe((result: boolean | { id: string, name: string, discount: number }[]) => {
|
||||
if (!!result) {
|
||||
this.bs.discount(result as { id: string, name: string, discount: number }[]);
|
||||
this.showDiscount().subscribe(
|
||||
(result: boolean | { id: string; name: string; discount: number }[]) => {
|
||||
if (result) {
|
||||
this.bs.discount(result as { id: string; name: string; discount: number }[]);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
billTypeDialog() {
|
||||
if (this.bs.bill.voucherType !== PrintType.Kot) {
|
||||
return observableOf(this.bs.bill.voucherType);
|
||||
} else {
|
||||
return this.dialog.open(BillTypeComponent).afterClosed().pipe(
|
||||
tap(x => {
|
||||
}
|
||||
return this.dialog
|
||||
.open(BillTypeComponent)
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
tap((x) => {
|
||||
if (!x) {
|
||||
throwError('No Bill Type Chosen');
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
confirmTableDialog(table: Table): Observable<{table: Table, confirmed: boolean}> {
|
||||
return this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Select Table?', content: 'Are you sure?'}
|
||||
}).afterClosed().pipe(
|
||||
map ((x: boolean) => ({table: table, confirmed: x}))
|
||||
);
|
||||
confirmTableDialog(table: Table): Observable<{ table: Table; confirmed: boolean }> {
|
||||
return this.dialog
|
||||
.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: { title: 'Select Table?', content: 'Are you sure?' },
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(map((x: boolean) => ({ table, confirmed: x })));
|
||||
}
|
||||
|
||||
confirmVoidDialog(reason: string): Observable<boolean | string> {
|
||||
return this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Void Bill?', content: 'Are you sure?'}
|
||||
}).afterClosed().pipe(
|
||||
map((x: boolean) => x ? reason : x)
|
||||
);
|
||||
return this.dialog
|
||||
.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: { title: 'Void Bill?', content: 'Are you sure?' },
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(map((x: boolean) => (x ? reason : x)));
|
||||
}
|
||||
|
||||
printBillAllowed(): boolean {
|
||||
@ -132,7 +133,10 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!this.bs.bill.id) {
|
||||
return true;
|
||||
}
|
||||
if (this.bs.bill.voucherType !== PrintType.Kot && this.auth.user.perms.indexOf('edit-printed-bill') === -1) {
|
||||
if (
|
||||
this.bs.bill.voucherType !== PrintType.Kot &&
|
||||
this.auth.user.perms.indexOf('edit-printed-bill') === -1
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (this.bs.bill.isVoid) {
|
||||
@ -149,27 +153,30 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (this.route.snapshot.queryParamMap.has('guest')) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get('guest');
|
||||
}
|
||||
this.showDiscount().pipe(
|
||||
tap((result: boolean | { id: string, name: string, discount: number }[]) => {
|
||||
if (!!result) {
|
||||
this.bs.discount(result as { id: string, name: string, discount: number }[]);
|
||||
}
|
||||
}),
|
||||
switchMap(() => this.billTypeDialog()),
|
||||
switchMap((x: boolean | PrintType) => {
|
||||
if (!!x) {
|
||||
return this.bs.printBill(guestBookId, x as PrintType);
|
||||
} else {
|
||||
this.showDiscount()
|
||||
.pipe(
|
||||
tap((result: boolean | { id: string; name: string; discount: number }[]) => {
|
||||
if (result) {
|
||||
this.bs.discount(result as { id: string; name: string; discount: number }[]);
|
||||
}
|
||||
}),
|
||||
switchMap(() => this.billTypeDialog()),
|
||||
switchMap((x: boolean | PrintType) => {
|
||||
if (x) {
|
||||
return this.bs.printBill(guestBookId, x as PrintType);
|
||||
}
|
||||
return throwError(x);
|
||||
}
|
||||
}),
|
||||
).subscribe(() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
() => {
|
||||
this.toaster.show('Error', 'No Bill Type Chosen');
|
||||
});
|
||||
}),
|
||||
)
|
||||
.subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
() => {
|
||||
this.toaster.show('Error', 'No Bill Type Chosen');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
receivePaymentAllowed(): boolean {
|
||||
@ -194,48 +201,56 @@ export class SalesHomeComponent implements OnInit {
|
||||
{
|
||||
id: 4,
|
||||
name: 'No Charge',
|
||||
amount: amount
|
||||
}
|
||||
amount,
|
||||
},
|
||||
],
|
||||
STAFF: [
|
||||
{
|
||||
id: 10,
|
||||
name: 'Staff Account',
|
||||
amount: amount
|
||||
}
|
||||
]
|
||||
amount,
|
||||
},
|
||||
],
|
||||
};
|
||||
return this.dialog.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: {title: (type === 'NO_CHARGE') ? 'NC for whom' : 'Staff name'}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((value: boolean | string) => {
|
||||
if (!!value) {
|
||||
return this.bs.receivePayment(types[type], value as string);
|
||||
} else {
|
||||
return throwError('Cancelled');
|
||||
}
|
||||
return this.dialog
|
||||
.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: { title: type === 'NO_CHARGE' ? 'NC for whom' : 'Staff name' },
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
receiveRegularPayment (type: string, amount: number): Observable<boolean> {
|
||||
return this.dialog.open(ReceivePaymentComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
type: type,
|
||||
amount: amount
|
||||
}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((value: boolean | {id: number, name: string, amount: number}[]) => {
|
||||
if (!!value) {
|
||||
return this.bs.receivePayment(value as { id: number, name: string, amount: number }[], '')
|
||||
} else {
|
||||
return throwError('Cancelled');
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
switchMap((value: boolean | string) => {
|
||||
if (value) {
|
||||
return this.bs.receivePayment(types[type], value as string);
|
||||
}
|
||||
})
|
||||
return throwError('Cancelled');
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
receiveRegularPayment(type: string, amount: number): Observable<boolean> {
|
||||
return this.dialog
|
||||
.open(ReceivePaymentComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
type,
|
||||
amount,
|
||||
},
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
switchMap((value: boolean | { id: number; name: string; amount: number }[]) => {
|
||||
if (value) {
|
||||
return this.bs.receivePayment(
|
||||
value as { id: number; name: string; amount: number }[],
|
||||
'',
|
||||
);
|
||||
}
|
||||
return throwError('Cancelled');
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
receivePayment() {
|
||||
if (!this.receivePaymentAllowed()) {
|
||||
return;
|
||||
@ -249,14 +264,18 @@ export class SalesHomeComponent implements OnInit {
|
||||
obs = this.receiveRegularPayment(type, amount);
|
||||
}
|
||||
obs.subscribe(() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
});
|
||||
}
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
});
|
||||
}
|
||||
|
||||
moveTableAllowed(): boolean {
|
||||
// TODO: Check if this condition should be "and" or "or"
|
||||
if (this.auth.user && this.auth.user.perms.indexOf('move-table') === -1 && this.auth.user.perms.indexOf('merge-tables') === -1) {
|
||||
if (
|
||||
this.auth.user &&
|
||||
this.auth.user.perms.indexOf('move-table') === -1 &&
|
||||
this.auth.user.perms.indexOf('merge-tables') === -1
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (!this.bs.bill.id) {
|
||||
@ -269,38 +288,43 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!this.moveTableAllowed()) {
|
||||
return;
|
||||
}
|
||||
const canMergeTables = (this.auth.user.perms.indexOf('merge-tables') !== -1);
|
||||
this.dialog.open(TablesDialogComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
list: this.tSer.running(),
|
||||
canChooseRunning: canMergeTables
|
||||
}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((x: boolean | Table) => {
|
||||
if (!!x) {
|
||||
return this.confirmTableDialog(x as Table);
|
||||
} else {
|
||||
const canMergeTables = this.auth.user.perms.indexOf('merge-tables') !== -1;
|
||||
this.dialog
|
||||
.open(TablesDialogComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
list: this.tSer.running(),
|
||||
canChooseRunning: canMergeTables,
|
||||
},
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
switchMap((x: boolean | Table) => {
|
||||
if (x) {
|
||||
return this.confirmTableDialog(x as Table);
|
||||
}
|
||||
return throwError('Please choose a table');
|
||||
}
|
||||
}),
|
||||
switchMap((value: { table: Table, confirmed: boolean }, index: number) => {
|
||||
}),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
switchMap((value: { table: Table; confirmed: boolean }, index: number) => {
|
||||
if (!value.confirmed) {
|
||||
return throwError('Please confirm move');
|
||||
} else if (value.table.status) {
|
||||
return this.bs.mergeTable(value.table);
|
||||
} else {
|
||||
return this.bs.moveTable(value.table);
|
||||
}
|
||||
}
|
||||
if (value.table.status) {
|
||||
return this.bs.mergeTable(value.table);
|
||||
}
|
||||
return this.bs.moveTable(value.table);
|
||||
}),
|
||||
)
|
||||
).subscribe(() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
x => {
|
||||
this.toaster.show('Error', x);
|
||||
});
|
||||
.subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
(x) => {
|
||||
this.toaster.show('Error', x);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
voidBillAllowed(): boolean {
|
||||
@ -317,42 +341,46 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!this.voidBillAllowed()) {
|
||||
return;
|
||||
}
|
||||
this.dialog.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: {
|
||||
title: 'Void Reason',
|
||||
reasons: [
|
||||
'Discount',
|
||||
'Printing fault',
|
||||
'Item changed',
|
||||
'Quantity reduced',
|
||||
'Costing bill for party',
|
||||
'Cashier mistake',
|
||||
'Management free sale',
|
||||
]
|
||||
}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((x: boolean | string) => {
|
||||
if (!!x) {
|
||||
return this.confirmVoidDialog(x as string);
|
||||
} else {
|
||||
return throwError('Please choose a reason to void the bill');
|
||||
}
|
||||
}),
|
||||
switchMap((x: boolean | string) => {
|
||||
if (!!x) {
|
||||
return this.bs.voidBill(x as string);
|
||||
} else {
|
||||
return throwError('You chose not to void the bill');
|
||||
}
|
||||
this.dialog
|
||||
.open(ReasonComponent, {
|
||||
// width: '750px'
|
||||
data: {
|
||||
title: 'Void Reason',
|
||||
reasons: [
|
||||
'Discount',
|
||||
'Printing fault',
|
||||
'Item changed',
|
||||
'Quantity reduced',
|
||||
'Costing bill for party',
|
||||
'Cashier mistake',
|
||||
'Management free sale',
|
||||
],
|
||||
},
|
||||
})
|
||||
).subscribe((x) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
x => {
|
||||
this.toaster.show('Error', x);
|
||||
});
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
switchMap((x: boolean | string) => {
|
||||
if (x) {
|
||||
return this.confirmVoidDialog(x as string);
|
||||
}
|
||||
return throwError('Please choose a reason to void the bill');
|
||||
}),
|
||||
switchMap((x: boolean | string) => {
|
||||
if (x) {
|
||||
return this.bs.voidBill(x as string);
|
||||
}
|
||||
return throwError('You chose not to void the bill');
|
||||
}),
|
||||
)
|
||||
.subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
(x) => {
|
||||
this.toaster.show('Error', x);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
splitBillAllowed(): boolean {
|
||||
@ -369,33 +397,38 @@ export class SalesHomeComponent implements OnInit {
|
||||
if (!this.splitBillAllowed()) {
|
||||
return;
|
||||
}
|
||||
this.dialog.open(TablesDialogComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
list: this.tSer.running(),
|
||||
canChooseRunning: false
|
||||
}
|
||||
}).afterClosed().pipe(
|
||||
switchMap((x: boolean | Table) => {
|
||||
if (!!x) {
|
||||
return this.confirmTableDialog(x as Table);
|
||||
} else {
|
||||
this.dialog
|
||||
.open(TablesDialogComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
list: this.tSer.running(),
|
||||
canChooseRunning: false,
|
||||
},
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
switchMap((x: boolean | Table) => {
|
||||
if (x) {
|
||||
return this.confirmTableDialog(x as Table);
|
||||
}
|
||||
return throwError('Please choose a table');
|
||||
}
|
||||
}),
|
||||
switchMap((value: { table: Table, confirmed: boolean }, index: number) => {
|
||||
}),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
switchMap((value: { table: Table; confirmed: boolean }, index: number) => {
|
||||
if (!value.confirmed) {
|
||||
return throwError('Please confirm split');
|
||||
} else {
|
||||
return this.bs.splitBill(value.table);
|
||||
}
|
||||
})
|
||||
).subscribe((x) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
x => {
|
||||
this.toaster.show('Error', x);
|
||||
});
|
||||
return this.bs.splitBill(value.table);
|
||||
}),
|
||||
)
|
||||
.subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigate(['/sales']);
|
||||
},
|
||||
(x) => {
|
||||
this.toaster.show('Error', x);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user