diff --git a/bookie/src/app/sales/home/sales-home.component.ts b/bookie/src/app/sales/home/sales-home.component.ts index 9de6fc4..40490e0 100644 --- a/bookie/src/app/sales/home/sales-home.component.ts +++ b/bookie/src/app/sales/home/sales-home.component.ts @@ -59,10 +59,15 @@ export class SalesHomeComponent { if (this.route.snapshot.queryParamMap.has('guest')) { guestBookId = this.route.snapshot.queryParamMap.get('guest'); } - this.bs.printKot(guestBookId).subscribe(() => { - this.toaster.show('Success', ''); - this.router.navigate(['/sales']); - }); + this.bs.printKot(guestBookId).subscribe( + () => { + this.toaster.show('Success', ''); + this.router.navigate(['/sales']); + }, + (result) => { + this.toaster.show('Error', result); + }, + ); } discountAllowed(): boolean { @@ -96,14 +101,7 @@ export class SalesHomeComponent { } return this.dialog .open(BillTypeComponent) - .afterClosed() - .pipe( - tap((x) => { - if (!x) { - throwError('No Bill Type Chosen'); - } - }), - ); + .afterClosed(); } confirmTableDialog(table: Table): Observable<{ table: Table; confirmed: boolean }> { @@ -161,20 +159,21 @@ export class SalesHomeComponent { } }), switchMap(() => this.billTypeDialog()), - switchMap((x: boolean | PrintType) => { + switchMap((x)=> { if (x) { - return this.bs.printBill(guestBookId, x as PrintType); + return observableOf(x); } - return throwError(x); + return throwError('No Bill Type Chosen') }), + switchMap((x: PrintType) => this.bs.printBill(guestBookId, x as PrintType)), ) .subscribe( () => { this.toaster.show('Success', ''); this.router.navigate(['/sales']); }, - () => { - this.toaster.show('Error', 'No Bill Type Chosen'); + (result) => { + this.toaster.show('Error', result); }, ); }