diff --git a/src/app/core/services/checkout.service.ts b/src/app/core/services/checkout.service.ts index f07e912..7899eda 100644 --- a/src/app/core/services/checkout.service.ts +++ b/src/app/core/services/checkout.service.ts @@ -21,9 +21,6 @@ export type StartCheckoutPayload = | { cart_id: number; } - | { - direct_item: DirectCheckoutItem; - } | { direct_items: DirectCheckoutItem[]; }; diff --git a/src/app/features/store/pages/store-home-page/store-home-page.component.ts b/src/app/features/store/pages/store-home-page/store-home-page.component.ts index ef00f75..c09b554 100644 --- a/src/app/features/store/pages/store-home-page/store-home-page.component.ts +++ b/src/app/features/store/pages/store-home-page/store-home-page.component.ts @@ -184,21 +184,23 @@ export class StoreHomePageComponent implements OnInit, OnDestroy { try { const checkoutService = this.injector.get(CheckoutService); const variantIds = event.variantIds ?? []; - const purchase = - variantIds.length > 1 - ? await this.startTicketCheckout( - checkoutService, - tenant.codigo, - event.product.id, - variantIds, - ) - : await checkoutService.startCheckout(tenant.codigo, { - direct_item: { + const directItems = + variantIds.length > 0 + ? variantIds.map((variantId) => ({ + catalog_item_id: event.product.id, + variant_id: variantId, + cantidad: 1, + })) + : [ + { catalog_item_id: event.product.id, variant_id: event.variant ?? null, cantidad: event.quantity, }, - }); + ]; + const purchase = await checkoutService.startCheckout(tenant.codigo, { + direct_items: directItems, + }); await this.router.navigate(['/checkout'], { queryParams: { purchase: purchase.id } }); } catch (error) { console.error('Failed to create direct purchase:', error); @@ -219,21 +221,6 @@ export class StoreHomePageComponent implements OnInit, OnDestroy { } } - private async startTicketCheckout( - checkoutService: CheckoutService, - tenantCode: string, - catalogItemId: number, - variantIds: number[], - ) { - return checkoutService.startCheckout(tenantCode, { - direct_items: variantIds.map((variantId) => ({ - catalog_item_id: catalogItemId, - variant_id: variantId, - cantidad: 1, - })), - }); - } - protected onAddToCart(event: ProductListCartEvent): void { this.cartService.addItem(event.product.id, event.variant ?? null, event.quantity).subscribe({ next: (response) => {