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:
2026-08-18 10:45:30 -03:00
parent 69f3569ccf
commit 6b2f8de210
18 changed files with 644 additions and 617 deletions

View File

@@ -36,10 +36,10 @@
</app-button>
<app-button
variant="secondary"
[disabled]="hasVariants() && selectedVariant() === null"
[disabled]="saving() || (hasVariants() && selectedVariant() === null)"
(click)="onAddToCart()"
>
Agregar al carrito
{{ saving() ? 'Guardando' : 'Agregar al carrito' }}
</app-button>
</div>
</div>

View File

@@ -24,6 +24,7 @@ export class ProductVerticalWithCartCardComponent {
readonly description = input<string>('');
readonly price = input<number>(0);
readonly variants = input<VerticalCartVariant[]>([]);
readonly saving = input(false);
readonly quantity = model<number>(1);
readonly selectedVariant = model<number | null>(null);
@@ -46,6 +47,10 @@ export class ProductVerticalWithCartCardComponent {
protected readonly hasVariants = computed(() => this.variants().length > 0);
protected onAddToCart(): void {
if (this.saving()) {
return;
}
this.addToCart.emit({ quantity: this.quantity(), variant: this.selectedVariant() });
}