feat: integrate quantity selector component into cart and product detail pages for enhanced functionality

This commit is contained in:
2026-07-02 09:01:30 -03:00
parent 394a1dde0d
commit 202205c038
8 changed files with 66 additions and 37 deletions

View File

@@ -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">

View File

@@ -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();