feat: integrate quantity selector component into cart and product detail pages for enhanced functionality
This commit is contained in:
@@ -54,11 +54,8 @@
|
||||
<section class="product-detail__section">
|
||||
<div class="product-detail__purchase">
|
||||
<app-quantity-selector
|
||||
[quantity]="quantity()"
|
||||
[(quantity)]="quantity"
|
||||
[max]="selectedVariant()?.stock ?? 1"
|
||||
(increase)="increaseQuantity()"
|
||||
(decrease)="decreaseQuantity()"
|
||||
(quantityChange)="quantity.set($event)"
|
||||
/>
|
||||
|
||||
<div class="product-detail__actions">
|
||||
|
||||
@@ -215,14 +215,7 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
protected increaseQuantity(): void {
|
||||
const currentStock = this.selectedVariant()?.stock ?? 1;
|
||||
this.quantity.update((current) => current < currentStock ? current + 1 : current);
|
||||
}
|
||||
|
||||
protected decreaseQuantity(): void {
|
||||
this.quantity.update((current) => Math.max(1, current - 1));
|
||||
}
|
||||
|
||||
protected addToCart(): void {
|
||||
const variant = this.selectedVariant();
|
||||
|
||||
Reference in New Issue
Block a user