feat: implement product attribute selector component and integrate into product detail page

This commit is contained in:
2026-07-01 10:48:05 -03:00
parent 1a7a6c28e6
commit 3ad29f959d
5 changed files with 71 additions and 2 deletions

View File

@@ -69,6 +69,7 @@
type="button"
class="product-detail__quantity-button"
aria-label="Aumentar cantidad"
[disabled]="quantity() >= (selectedVariant()?.stock ?? 1)"
(click)="increaseQuantity()"
>
+
@@ -80,11 +81,12 @@
class="product-detail__cta"
variant="secondary"
type="button"
[disabled]="!selectedVariant()"
>
Agregar al carrito
</app-button>
<app-button class="product-detail__cta" type="button">
<app-button class="product-detail__cta" type="button" [disabled]="!selectedVariant()">
Comprar
</app-button>
</div>

View File

@@ -154,10 +154,14 @@ export class ProductDetailPageComponent implements OnInit, OnDestroy {
protected onVariantChange(variant: ProductVariantMap | null): void {
this.selectedVariant.set(variant);
if (variant && this.quantity() > variant.stock) {
this.quantity.set(Math.max(1, variant.stock));
}
}
protected increaseQuantity(): void {
this.quantity.update((current) => current + 1);
const currentStock = this.selectedVariant()?.stock ?? 1;
this.quantity.update((current) => current < currentStock ? current + 1 : current);
}
protected decreaseQuantity(): void {