feat: implement direct purchase functionality and enhance product buy events
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
|
||||
<div class="product-vertical-with-cart-card__actions">
|
||||
<app-button variant="primary" (click)="buy.emit()">Comprar</app-button>
|
||||
<app-button variant="primary" (click)="onBuy()">Comprar</app-button>
|
||||
<app-button variant="secondary" (click)="onAddToCart()"> Agregar al carrito </app-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ProductVerticalWithCartCardComponent {
|
||||
|
||||
readonly quantity = model<number>(1);
|
||||
|
||||
readonly buy = output<void>();
|
||||
readonly buy = output<{ quantity: number }>();
|
||||
readonly addToCart = output<{ quantity: number }>();
|
||||
|
||||
protected readonly formattedPrice = computed(() => this.formatCurrency(this.price()));
|
||||
@@ -26,6 +26,10 @@ export class ProductVerticalWithCartCardComponent {
|
||||
this.addToCart.emit({ quantity: this.quantity() });
|
||||
}
|
||||
|
||||
protected onBuy(): void {
|
||||
this.buy.emit({ quantity: this.quantity() });
|
||||
}
|
||||
|
||||
private formatCurrency(value: number): string {
|
||||
const rounded = Math.round(value);
|
||||
const parts = rounded.toString().split('.');
|
||||
|
||||
Reference in New Issue
Block a user