From 311464e5931eb6980094e4d5142270dc9e52a9e2 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Thu, 27 Aug 2026 06:06:30 +0000 Subject: [PATCH] csdxz --- .../bundle-detail/bundle-detail.component.ts | 2 +- .../bundle-list/bundle-list.component.ts | 2 +- bookie/src/app/bundles/bundle.ts | 5 +- bookie/src/app/customers/customer.service.ts | 8 +- bookie/src/app/devices/device.service.ts | 4 +- .../src/app/guest-book/guest-book.service.ts | 12 +-- .../menu-category/menu-category.service.ts | 15 ++-- .../modifier-category.service.ts | 4 +- bookie/src/app/modifiers/modifier.service.ts | 4 +- bookie/src/app/printers/printer.service.ts | 4 +- .../product-detail.component.ts | 2 +- .../product-list/product-list.component.ts | 2 +- bookie/src/app/product/product.service.ts | 12 +-- bookie/src/app/regimes/regime.service.ts | 4 +- bookie/src/app/roles/role.service.ts | 4 +- .../sale-category/sale-category.service.ts | 4 +- bookie/src/app/sales/bills/bill.ts | 3 +- bookie/src/app/sales/bills/bills.component.ts | 2 +- .../choose-customer.component.ts | 73 +++++++------------ .../discount/customer-discounts.service.ts | 9 ++- .../app/sales/home/sales-home.component.ts | 4 +- .../menu-categories.component.ts | 2 +- .../section-printer.service.ts | 4 +- bookie/src/app/sections/section.service.ts | 4 +- .../settle-option/settle-option.service.ts | 4 +- bookie/src/app/tables/table.service.ts | 4 +- bookie/src/app/taxes/tax.service.ts | 4 +- .../temporal-product-detail.component.ts | 2 +- .../temporal-product-list.component.ts | 2 +- .../temporal-product.service.ts | 4 +- .../update-product-prices.component.ts | 2 +- bookie/src/app/users/user.service.ts | 4 +- 32 files changed, 98 insertions(+), 117 deletions(-) diff --git a/bookie/src/app/bundles/bundle-detail/bundle-detail.component.ts b/bookie/src/app/bundles/bundle-detail/bundle-detail.component.ts index 9d6a518..bd2b52c 100644 --- a/bookie/src/app/bundles/bundle-detail/bundle-detail.component.ts +++ b/bookie/src/app/bundles/bundle-detail/bundle-detail.component.ts @@ -68,7 +68,7 @@ export class BundleDetailComponent { private snackBar = inject(MatSnackBar); private ser = inject(BundleService); private productSer = inject(ProductService); - menuCategoriesResource = this.menuCategoryService.list(undefined); + menuCategoriesResource = this.menuCategoryService.list(); menuCategories = computed(() => this.menuCategoriesResource.value() ?? []); saleCategoriesResource = this.saleCategoryService.list(); saleCategories = computed(() => this.saleCategoriesResource.value() ?? []); diff --git a/bookie/src/app/bundles/bundle-list/bundle-list.component.ts b/bookie/src/app/bundles/bundle-list/bundle-list.component.ts index 5b58072..940fad2 100644 --- a/bookie/src/app/bundles/bundle-list/bundle-list.component.ts +++ b/bookie/src/app/bundles/bundle-list/bundle-list.component.ts @@ -42,7 +42,7 @@ export class BundleListComponent { private bundleService = inject(BundleService); private toCsv = inject(ToCsvService); - menuCategoriesResource = this.menuCategoryService.list(undefined); + menuCategoriesResource = this.menuCategoryService.list(); listResource = this.bundleService.list(); menuCategoryFilter = signal(''); diff --git a/bookie/src/app/bundles/bundle.ts b/bookie/src/app/bundles/bundle.ts index 5f8cb25..6ad3d9b 100644 --- a/bookie/src/app/bundles/bundle.ts +++ b/bookie/src/app/bundles/bundle.ts @@ -1,16 +1,15 @@ import { MenuCategory } from '../core/menu-category'; +import { ProductQuery } from '../core/product-query'; import { SaleCategory } from '../core/sale-category'; export class BundleItem { - id?: string; - itemId: string; + sku: ProductQuery | undefined; name: string; salePrice: number; quantity: number; printInBill: boolean; public constructor(init?: Partial) { - this.itemId = ''; this.name = ''; this.salePrice = 0; this.quantity = 0; diff --git a/bookie/src/app/customers/customer.service.ts b/bookie/src/app/customers/customer.service.ts index eece7ed..8fb21a1 100644 --- a/bookie/src/app/customers/customer.service.ts +++ b/bookie/src/app/customers/customer.service.ts @@ -20,9 +20,9 @@ export class CustomerService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } @@ -86,9 +86,9 @@ export class CustomerService { .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable; } - autocomplete(query: Signal | string | null): HttpResourceRef { + autocomplete(query: Signal): HttpResourceRef { return httpResource(() => { - const qVal = typeof query === 'function' ? query() : query; + const qVal = query(); return `${url}/query?q=${qVal ?? ''}`; }); } diff --git a/bookie/src/app/devices/device.service.ts b/bookie/src/app/devices/device.service.ts index 18e881c..5eb53f7 100644 --- a/bookie/src/app/devices/device.service.ts +++ b/bookie/src/app/devices/device.service.ts @@ -16,9 +16,9 @@ export class DeviceService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/guest-book/guest-book.service.ts b/bookie/src/app/guest-book/guest-book.service.ts index 98f56e0..e12a4dc 100644 --- a/bookie/src/app/guest-book/guest-book.service.ts +++ b/bookie/src/app/guest-book/guest-book.service.ts @@ -20,21 +20,21 @@ export class GuestBookService { private log = inject(ErrorLoggerService); get( - id: Signal | string | null, - type: Signal | GuestBookType | string = '', + id: Signal, + type?: Signal, ): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; - const typeVal = typeof type === 'function' ? type() : type; + const idVal = id(); + const typeVal = type ? type() : ''; const options = { params: new HttpParams().set('t', typeVal) }; const getUrl: string = idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return { url: getUrl, ...options }; }); } - list(date: Signal | string | null): HttpResourceRef { + list(date: Signal): HttpResourceRef { return httpResource(() => { - const dateVal = typeof date === 'function' ? date() : date; + const dateVal = date(); const options = { params: new HttpParams().set('q', dateVal === null ? '' : dateVal) }; return { url: `${url}/list`, ...options }; }); diff --git a/bookie/src/app/menu-category/menu-category.service.ts b/bookie/src/app/menu-category/menu-category.service.ts index f1d9350..d6235fb 100644 --- a/bookie/src/app/menu-category/menu-category.service.ts +++ b/bookie/src/app/menu-category/menu-category.service.ts @@ -19,20 +19,21 @@ export class MenuCategoryService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } - list(shouldHaveActiveProducts: boolean | undefined): HttpResourceRef { + list(shouldHaveActiveProducts?: Signal): HttpResourceRef { return httpResource(() => { - const options = { params: new HttpParams() }; - if (shouldHaveActiveProducts) { - options.params = options.params.set('p', 'true'); + let params = new HttpParams(); + const active = shouldHaveActiveProducts ? shouldHaveActiveProducts() : undefined; + if (active) { + params = params.set('p', 'true'); } - return { url: `${url}/list`, ...options }; + return { url: `${url}/list`, params }; }); } diff --git a/bookie/src/app/modifier-categories/modifier-category.service.ts b/bookie/src/app/modifier-categories/modifier-category.service.ts index d527c5d..7dc3b7e 100644 --- a/bookie/src/app/modifier-categories/modifier-category.service.ts +++ b/bookie/src/app/modifier-categories/modifier-category.service.ts @@ -19,9 +19,9 @@ export class ModifierCategoryService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/modifiers/modifier.service.ts b/bookie/src/app/modifiers/modifier.service.ts index 5be4b9e..64b159a 100644 --- a/bookie/src/app/modifiers/modifier.service.ts +++ b/bookie/src/app/modifiers/modifier.service.ts @@ -18,9 +18,9 @@ export class ModifierService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/printers/printer.service.ts b/bookie/src/app/printers/printer.service.ts index 7aa4023..41819fc 100644 --- a/bookie/src/app/printers/printer.service.ts +++ b/bookie/src/app/printers/printer.service.ts @@ -19,9 +19,9 @@ export class PrinterService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/product/product-detail/product-detail.component.ts b/bookie/src/app/product/product-detail/product-detail.component.ts index daca4e3..e7f243e 100644 --- a/bookie/src/app/product/product-detail/product-detail.component.ts +++ b/bookie/src/app/product/product-detail/product-detail.component.ts @@ -69,7 +69,7 @@ export class ProductDetailComponent { saleCategoriesResource = this.saleCategoryService.list(); - menuCategoriesResource = this.menuCategoryService.list(undefined); + menuCategoriesResource = this.menuCategoryService.list(); itemResource = this.ser.get(this.id); diff --git a/bookie/src/app/product/product-list/product-list.component.ts b/bookie/src/app/product/product-list/product-list.component.ts index 627624b..f7a7e8b 100644 --- a/bookie/src/app/product/product-list/product-list.component.ts +++ b/bookie/src/app/product/product-list/product-list.component.ts @@ -48,7 +48,7 @@ export class ProductListComponent { private toCsv = inject(ToCsvService); private ser = inject(ProductService); - menuCategoriesResource = this.menuCategoryService.list(undefined); + menuCategoriesResource = this.menuCategoryService.list(); listResource = this.ser.list(); diff --git a/bookie/src/app/product/product.service.ts b/bookie/src/app/product/product.service.ts index 28d9e6f..86084f8 100644 --- a/bookie/src/app/product/product.service.ts +++ b/bookie/src/app/product/product.service.ts @@ -19,9 +19,9 @@ export class ProductService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } @@ -30,16 +30,16 @@ export class ProductService { return httpResource(() => `${url}/list`); } - listOfSaleCategory(id: Signal | string): HttpResourceRef { + listOfSaleCategory(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return `${url}/query?sc=${idVal ?? ''}`; }); } - listIsActiveOfCategory(id: Signal | string): HttpResourceRef { + listIsActiveOfCategory(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return `${url}/query?mc=${idVal ?? ''}`; }); } diff --git a/bookie/src/app/regimes/regime.service.ts b/bookie/src/app/regimes/regime.service.ts index 06652bd..ee2af75 100644 --- a/bookie/src/app/regimes/regime.service.ts +++ b/bookie/src/app/regimes/regime.service.ts @@ -19,9 +19,9 @@ export class RegimeService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | number | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined || isNaN(idVal) ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/roles/role.service.ts b/bookie/src/app/roles/role.service.ts index f52d9fa..cf474d5 100644 --- a/bookie/src/app/roles/role.service.ts +++ b/bookie/src/app/roles/role.service.ts @@ -19,9 +19,9 @@ export class RoleService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/sale-category/sale-category.service.ts b/bookie/src/app/sale-category/sale-category.service.ts index 2bc4b16..288de81 100644 --- a/bookie/src/app/sale-category/sale-category.service.ts +++ b/bookie/src/app/sale-category/sale-category.service.ts @@ -19,9 +19,9 @@ export class SaleCategoryService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/sales/bills/bill.ts b/bookie/src/app/sales/bills/bill.ts index f45d791..641bf6c 100644 --- a/bookie/src/app/sales/bills/bill.ts +++ b/bookie/src/app/sales/bills/bill.ts @@ -1,3 +1,4 @@ +import { Customer } from '../../core/customer'; import { Table } from '../../core/table'; import { User } from '../../core/user'; import { GuestBook } from '../../guest-book/guest-book'; @@ -17,7 +18,7 @@ export class Bill { kotId: string; billId: string; table: Table; - customer: { id: string; name: string } | null; + customer: Customer | null; guest: GuestBook; reason: string; voucherType: VoucherType; diff --git a/bookie/src/app/sales/bills/bills.component.ts b/bookie/src/app/sales/bills/bills.component.ts index 2e4117f..637af01 100644 --- a/bookie/src/app/sales/bills/bills.component.ts +++ b/bookie/src/app/sales/bills/bills.component.ts @@ -137,7 +137,7 @@ export class BillsComponent implements OnInit { const dialogRef = this.dialog.open(ChooseCustomerComponent, { maxWidth: '100%', width: '50%', - data: this.bs.bill.customer?.id, + data: this.bs.bill.customer, }); dialogRef.afterClosed().subscribe((result: boolean | Customer) => { diff --git a/bookie/src/app/sales/choose-customer/choose-customer.component.ts b/bookie/src/app/sales/choose-customer/choose-customer.component.ts index 26680f1..85a2436 100644 --- a/bookie/src/app/sales/choose-customer/choose-customer.component.ts +++ b/bookie/src/app/sales/choose-customer/choose-customer.component.ts @@ -1,5 +1,5 @@ import { CdkScrollableModule } from '@angular/cdk/scrolling'; -import { Component, inject, signal, computed, effect, debounced } from '@angular/core'; +import { Component, inject, computed, debounced, linkedSignal, signal } from '@angular/core'; import { form, FormField } from '@angular/forms/signals'; import { MatAutocompleteSelectedEvent, MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatButtonModule } from '@angular/material/button'; @@ -14,6 +14,7 @@ import { Customer } from '../../core/customer'; import { CustomerService } from '../../customers/customer.service'; export interface ChooseCustomerFormData { + id: string; name: string; phone: string; address: string; @@ -40,59 +41,36 @@ export interface ChooseCustomerFormData { ], }) export class ChooseCustomerComponent { - data = inject(MAT_DIALOG_DATA); + data = inject(MAT_DIALOG_DATA); // Customer ID private ser = inject(CustomerService); dialogRef = inject>(MatDialogRef); - formModel = signal({ - name: '', - phone: '', - address: '', - printInBill: false, - discounts: [], + + item = signal(this.data ?? new Customer()); + + formModel = linkedSignal({ + source: () => this.item(), + computation: (data) => ({ + id: data.id, + name: data.name, + phone: data.phone, + address: data.address ?? '', + printInBill: data.printInBill, + discounts: data.discounts.map((x) => ({ + discount: x.discount ? x.discount * 100 : null, + })), + }), }); form = form(this.formModel); - item: Customer = new Customer(); phoneSignal = computed(() => { - const p = this.formModel().phone; - return p === this.item.phone ? '' : p; + return this.formModel().phone; }); debouncedPhone = debounced(this.phoneSignal, 150); - customersResource = this.ser.autocomplete(computed(() => this.debouncedPhone.value())); - customers = computed(() => { - if (!this.debouncedPhone.value()) return []; - return this.customersResource.value() ?? []; - }); - - constructor() { - const data = this.data; - - if (data) { - const res = this.ser.get(data); - effect(() => { - const x = res.value(); - if (x) { - this.showItem(x); - } - }); - } - } - - showItem(item: Customer) { - this.item = item; - this.formModel.set({ - name: item.name, - phone: item.phone, - address: item.address ?? '', - printInBill: item.printInBill, - discounts: item.discounts.map((x) => ({ - discount: x.discount ? x.discount * 100 : null, - })), - }); - } + customersResource = this.ser.autocomplete(this.debouncedPhone.value); + customers = computed(() => { return this.customersResource.value() ?? [] }); save() { const customer = this.getItem(); @@ -109,7 +87,7 @@ export class ChooseCustomerComponent { selected(event: MatAutocompleteSelectedEvent): void { const customer: Customer = event.option.value; - this.showItem(customer); + this.item.set(customer); } getItem(): Customer { @@ -117,16 +95,15 @@ export class ChooseCustomerComponent { const array = formModel.discounts; return new Customer({ - ...this.item, - id: this.item.phone.trim() !== formModel.phone?.trim() ? '' : this.item.id, + id: formModel.id, name: formModel.name ?? '', phone: formModel.phone ?? '', address: formModel.address ?? '', printInBill: formModel.printInBill ?? false, - discounts: this.item.discounts.map((item, index) => { + discounts: formModel.discounts.map((item, index) => { const array_item = array?.[index]; return { - ...item, + ...this.item().discounts?.[index], discount: array_item && array_item?.discount ? Math.max(Math.min(round(array_item.discount / 100, 5), 100), 0) : 0, }; diff --git a/bookie/src/app/sales/discount/customer-discounts.service.ts b/bookie/src/app/sales/discount/customer-discounts.service.ts index 0d4720e..2d5e43e 100644 --- a/bookie/src/app/sales/discount/customer-discounts.service.ts +++ b/bookie/src/app/sales/discount/customer-discounts.service.ts @@ -1,5 +1,5 @@ import { httpResource, HttpResourceRef } from '@angular/common/http'; -import { Injectable, inject, Injector } from '@angular/core'; +import { Injectable, inject, Injector, Signal } from '@angular/core'; import { DiscountItem } from './discount-item'; @@ -11,8 +11,11 @@ const url = '/api/customer-discounts'; export class CustomerDiscountsService { private injector = inject(Injector); - list(id: string | undefined): HttpResourceRef { - return httpResource(() => (id === undefined ? url : `${url}/${id}`), { + list(id: Signal): HttpResourceRef { + return httpResource(() => { + const idVal = id(); + return idVal === undefined ? url : `${url}/${idVal}`; + }, { injector: this.injector, }); } diff --git a/bookie/src/app/sales/home/sales-home.component.ts b/bookie/src/app/sales/home/sales-home.component.ts index 607a54f..c6e555f 100644 --- a/bookie/src/app/sales/home/sales-home.component.ts +++ b/bookie/src/app/sales/home/sales-home.component.ts @@ -1,4 +1,4 @@ -import { Component, inject, computed } from '@angular/core'; +import { Component, inject, computed, signal } from '@angular/core'; import { MatCardModule } from '@angular/material/card'; import { MatRippleModule } from '@angular/material/core'; import { MatDialog } from '@angular/material/dialog'; @@ -87,7 +87,7 @@ export class SalesHomeComponent { if (this.discountAllowed()) { const dialogRef = this.dialog.open(DiscountComponent, { // width: '750px', - data: this.customerDiscountsService.list(this.bs.bill.customer?.id), + data: this.customerDiscountsService.list(signal(this.bs.bill.customer?.id)), }); return dialogRef.afterClosed(); } diff --git a/bookie/src/app/sales/menu-categories/menu-categories.component.ts b/bookie/src/app/sales/menu-categories/menu-categories.component.ts index 3872b9f..d86eb2b 100644 --- a/bookie/src/app/sales/menu-categories/menu-categories.component.ts +++ b/bookie/src/app/sales/menu-categories/menu-categories.component.ts @@ -13,7 +13,7 @@ import { MenuCategoryService } from '../../menu-category/menu-category.service'; }) export class MenuCategoriesComponent { private menuCategoryService = inject(MenuCategoryService); - listResource = this.menuCategoryService.list(undefined); + listResource = this.menuCategoryService.list(); list = computed(() => this.listResource.value() ?? []); } diff --git a/bookie/src/app/section-printers/section-printer.service.ts b/bookie/src/app/section-printers/section-printer.service.ts index 354396c..1f4ea17 100644 --- a/bookie/src/app/section-printers/section-printer.service.ts +++ b/bookie/src/app/section-printers/section-printer.service.ts @@ -19,9 +19,9 @@ export class SectionPrinterService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/sections/section.service.ts b/bookie/src/app/sections/section.service.ts index e6e7588..3acddc9 100644 --- a/bookie/src/app/sections/section.service.ts +++ b/bookie/src/app/sections/section.service.ts @@ -19,9 +19,9 @@ export class SectionService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef
{ + get(id: Signal): HttpResourceRef
{ return httpResource
(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/settle-option/settle-option.service.ts b/bookie/src/app/settle-option/settle-option.service.ts index f2d3a52..fc76988 100644 --- a/bookie/src/app/settle-option/settle-option.service.ts +++ b/bookie/src/app/settle-option/settle-option.service.ts @@ -20,9 +20,9 @@ export class SettleOptionService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/tables/table.service.ts b/bookie/src/app/tables/table.service.ts index f274f36..7f2168e 100644 --- a/bookie/src/app/tables/table.service.ts +++ b/bookie/src/app/tables/table.service.ts @@ -20,10 +20,10 @@ export class TableService { private log = inject(ErrorLoggerService); private injector = inject(Injector); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef
{ return httpResource
( () => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }, { injector: this.injector }, diff --git a/bookie/src/app/taxes/tax.service.ts b/bookie/src/app/taxes/tax.service.ts index d41644d..4553db0 100644 --- a/bookie/src/app/taxes/tax.service.ts +++ b/bookie/src/app/taxes/tax.service.ts @@ -19,9 +19,9 @@ export class TaxService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); } diff --git a/bookie/src/app/temporal-product/temporal-product-detail/temporal-product-detail.component.ts b/bookie/src/app/temporal-product/temporal-product-detail/temporal-product-detail.component.ts index 91b24f7..d3f345c 100644 --- a/bookie/src/app/temporal-product/temporal-product-detail/temporal-product-detail.component.ts +++ b/bookie/src/app/temporal-product/temporal-product-detail/temporal-product-detail.component.ts @@ -76,7 +76,7 @@ export class TemporalProductDetailComponent { saleCategoriesResource = this.saleCategoryService.list(); - menuCategoriesResource = this.menuCategoryService.list(undefined); + menuCategoriesResource = this.menuCategoryService.list(); itemResource = this.ser.get(this.id); diff --git a/bookie/src/app/temporal-product/temporal-product-list/temporal-product-list.component.ts b/bookie/src/app/temporal-product/temporal-product-list/temporal-product-list.component.ts index 752fb41..52d8c14 100644 --- a/bookie/src/app/temporal-product/temporal-product-list/temporal-product-list.component.ts +++ b/bookie/src/app/temporal-product/temporal-product-list/temporal-product-list.component.ts @@ -42,7 +42,7 @@ export class TemporalProductListComponent { private temporalProductService = inject(TemporalProductService); saleCategoriesResource = this.saleCategoryService.list(); - menuCategoriesResource = this.menuCategoryService.list(undefined); + menuCategoriesResource = this.menuCategoryService.list(); listResource = this.temporalProductService.list(); menuCategoryFilter = signal(''); diff --git a/bookie/src/app/temporal-product/temporal-product.service.ts b/bookie/src/app/temporal-product/temporal-product.service.ts index 195fe02..799dcf3 100644 --- a/bookie/src/app/temporal-product/temporal-product.service.ts +++ b/bookie/src/app/temporal-product/temporal-product.service.ts @@ -18,9 +18,9 @@ export class TemporalProductService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return `${url}/${idVal ?? ''}`; }); } diff --git a/bookie/src/app/update-product-prices/update-product-prices.component.ts b/bookie/src/app/update-product-prices/update-product-prices.component.ts index ef57339..0ba1d77 100644 --- a/bookie/src/app/update-product-prices/update-product-prices.component.ts +++ b/bookie/src/app/update-product-prices/update-product-prices.component.ts @@ -53,7 +53,7 @@ export class UpdateProductPricesComponent { infoResource = this.ser.get(this.id, this.date); - menuCategoriesResource = this.menuCategoryService.list(undefined); + menuCategoriesResource = this.menuCategoryService.list(); info = computed(() => this.infoResource.value() ?? new UpdateProductPrices()); dataSource = computed(() => this.info().items); diff --git a/bookie/src/app/users/user.service.ts b/bookie/src/app/users/user.service.ts index 5cf2812..6477ea2 100644 --- a/bookie/src/app/users/user.service.ts +++ b/bookie/src/app/users/user.service.ts @@ -19,9 +19,9 @@ export class UserService { private http = inject(HttpClient); private log = inject(ErrorLoggerService); - get(id: Signal | string | null): HttpResourceRef { + get(id: Signal): HttpResourceRef { return httpResource(() => { - const idVal = typeof id === 'function' ? id() : id; + const idVal = id(); return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; }); }