feat: enhance product ticket selector and vertical cart card components
- Refactor ProductTicketSelectorComponent to improve variant selection logic and error handling. - Introduce a new signal for variant attributes and manage variant loading more efficiently. - Update the UI to reflect saving state in ProductVerticalWithCartCardComponent, preventing actions while saving. - Adjust button text based on saving state for better user feedback.
This commit is contained in:
@@ -34,7 +34,9 @@
|
||||
<app-button variant="primary" (click)="onBuy()"> Comprar </app-button>
|
||||
</div>
|
||||
<div class="product-row-card__btn-wrapper">
|
||||
<app-button variant="secondary" (click)="onAddToCart()"> Agregar al carrito </app-button>
|
||||
<app-button variant="secondary" [disabled]="saving()" (click)="onAddToCart()">
|
||||
{{ saving() ? 'Guardando' : 'Agregar al carrito' }}
|
||||
</app-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,6 +27,7 @@ export class ProductRowCardComponent {
|
||||
readonly description = input<string>('');
|
||||
readonly price = input<number>(0);
|
||||
readonly variants = input<Variant[]>([]);
|
||||
readonly saving = input(false);
|
||||
|
||||
// Internal state models
|
||||
readonly quantity = model<number>(1);
|
||||
@@ -51,6 +52,10 @@ export class ProductRowCardComponent {
|
||||
readonly formattedPrice = computed(() => this.formatCurrency(this.effectivePrice()));
|
||||
|
||||
protected onAddToCart(): void {
|
||||
if (this.saving()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.addToCart.emit({
|
||||
quantity: this.quantity(),
|
||||
variant: this.selectedVariant(),
|
||||
|
||||
Reference in New Issue
Block a user