fda
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Component, inject, computed, signal } from '@angular/core';
|
||||
import { Component, inject, computed, signal, input } from '@angular/core';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatRippleModule } from '@angular/material/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { map, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
@@ -31,7 +31,6 @@ import { TablesDialogComponent } from '../tables-dialog/tables-dialog.component'
|
||||
imports: [MatRippleModule, RouterLink, MatCardModule],
|
||||
})
|
||||
export class SalesHomeComponent {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dialog = inject(MatDialog);
|
||||
private auth = inject(AuthService);
|
||||
@@ -40,6 +39,7 @@ export class SalesHomeComponent {
|
||||
private tableService = inject(TableService);
|
||||
private customerDiscountsService = inject(CustomerDiscountsService);
|
||||
private bs = inject(BillService);
|
||||
guest = input(null, { transform: (v: string | null | undefined) => v ?? null });
|
||||
|
||||
saleCategoriesResource = this.saleCategoryService.list();
|
||||
splitBillCategories = computed(() => {
|
||||
@@ -64,11 +64,7 @@ export class SalesHomeComponent {
|
||||
if (!this.printKotAllowed()) {
|
||||
return;
|
||||
}
|
||||
let guestBookId = null;
|
||||
if (this.route.snapshot.queryParamMap.has('guest')) {
|
||||
guestBookId = this.route.snapshot.queryParamMap.get('guest');
|
||||
}
|
||||
this.bs.printKot(guestBookId).subscribe({
|
||||
this.bs.printKot(this.guest()).subscribe({
|
||||
next: () => {
|
||||
this.snackBar.open('', 'Success');
|
||||
this.router.navigate(['/sales']);
|
||||
@@ -149,10 +145,6 @@ export class SalesHomeComponent {
|
||||
if (!this.printBillAllowed()) {
|
||||
return;
|
||||
}
|
||||
let guestBookId: string | null = null;
|
||||
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 }[]) => {
|
||||
@@ -169,7 +161,7 @@ export class SalesHomeComponent {
|
||||
}
|
||||
throw new Error('No Bill Type Chosen');
|
||||
}),
|
||||
switchMap((x: VoucherType) => this.bs.printBill(guestBookId, x as VoucherType)),
|
||||
switchMap((x: VoucherType) => this.bs.printBill(this.guest(), x as VoucherType)),
|
||||
)
|
||||
.subscribe({
|
||||
next: () => {
|
||||
|
||||
Reference in New Issue
Block a user