Show proper error messages on Save Bill / Save Kot

This commit is contained in:
Amritanshu Agrawal 2020-10-11 11:59:37 +05:30
parent 7baf79c3fa
commit 73f83f1aa7
1 changed files with 16 additions and 17 deletions

View File

@ -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);
},
);
}