Feature: Open bill using bill number

This commit is contained in:
2020-12-24 12:58:46 +05:30
parent 98c75f66c9
commit 161896154d
17 changed files with 234 additions and 29 deletions
@@ -1,7 +1,11 @@
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { map } from 'rxjs/operators';
import { Table } from '../../core/table';
import { ToasterService } from '../../core/toaster.service';
import { BillNumberComponent } from '../bill-number/bill-number.component';
@Component({
selector: 'app-running-tables',
@@ -11,7 +15,12 @@ import { Table } from '../../core/table';
export class RunningTablesComponent implements OnInit {
list: Table[] = [];
constructor(private router: Router, private route: ActivatedRoute) {}
constructor(
private dialog: MatDialog,
private router: Router,
private route: ActivatedRoute,
private toaster: ToasterService,
) {}
ngOnInit() {
this.route.data.subscribe((value) => {
@@ -33,4 +42,22 @@ export class RunningTablesComponent implements OnInit {
};
this.router.navigate(['/sales', 'bill'], navigationExtras);
}
openBill() {
return this.dialog
.open(BillNumberComponent)
.afterClosed()
.pipe(
map((x) => {
if (x === undefined || x === false) {
throw new Error('Invalid Bill Number');
}
return x;
}),
)
.subscribe(
(x) => this.router.navigate(['/sales', 'bill'], { queryParams: { bill: x } }),
(x) => this.toaster.show('Error', x),
);
}
}