diff --git a/src/app/product-selection/product-selection.component.html b/src/app/product-selection/product-selection.component.html index 46f83fd..0712a8f 100644 --- a/src/app/product-selection/product-selection.component.html +++ b/src/app/product-selection/product-selection.component.html @@ -1,4 +1,4 @@ - - + \ No newline at end of file diff --git a/src/app/product-selection/product-selection.component.ts b/src/app/product-selection/product-selection.component.ts index dde4d94..8b5f224 100644 --- a/src/app/product-selection/product-selection.component.ts +++ b/src/app/product-selection/product-selection.component.ts @@ -27,13 +27,8 @@ export type Product = { export class ProductSelectionComponent implements OnInit { products = signal([]); - - selectedProductId = signal(null); - - selectedProduct = computed(() => { - const id = this.selectedProductId(); - return id ? this.products().find(p => p.id === id) || null : null; - }); + + selectedProduct = signal(null); quantity = signal(1); @@ -46,8 +41,8 @@ export class ProductSelectionComponent implements OnInit { this.productService.getProducts().subscribe(products => this.products.set(products)); } - onProductChange(productId: number) { - this.selectedProductId.set(productId); + onProductChange(selectedProduct: Product) { + this.selectedProduct.set(selectedProduct); const product = this.selectedProduct(); if (product) { this.productChange.emit(product);