feat(purchase-detail): update item details structure and handle null values in mapping

This commit is contained in:
2026-07-21 10:22:32 -03:00
parent 938d15bf83
commit 8e44fa5a46
2 changed files with 12 additions and 12 deletions

View File

@@ -24,7 +24,7 @@ export interface PurchaseSummaryResponse extends PurchaseStatusResponse {
export interface PurchaseDetailAttributeResponse {
name: string;
value: string | null;
value: string | number | boolean | null;
}
export interface PurchaseDetailItemResponse {
@@ -32,16 +32,15 @@ export interface PurchaseDetailItemResponse {
quantity: number;
unit_price: string;
line_total: string;
product: {
id: number;
source_catalog_item_id: number | null;
source_variant_id: number | null;
item_details: {
nombre: string;
descripcion: string | null;
slug: string;
imagen: string | null;
} | null;
variant: {
id: number;
attributes: PurchaseDetailAttributeResponse[];
} | null;
};
}
export interface PurchaseDetailResponse extends PurchaseStatusResponse {
@@ -52,10 +51,11 @@ export interface PurchaseDetailResponse extends PurchaseStatusResponse {
created_at: string | null;
payment_method: string | null;
dni: string | null;
transfer_payer_dni: string | null;
telefono: string | null;
nombre_apellido: string | null;
email: string | null;
items_source: 'purchase' | 'cart' | null;
items_source: 'purchase';
items: PurchaseDetailItemResponse[];
subtotal: string;
total: string;

View File

@@ -79,12 +79,12 @@ export class PurchaseDetailPage implements OnInit {
private mapItems(purchase: PurchaseDetailResponse): PurchaseItemViewModel[] {
return purchase.items.map((item) => ({
id: item.id,
title: item.product?.nombre ?? 'Producto sin nombre',
imageUrl: item.product?.imagen ?? null,
title: item.item_details.nombre || 'Producto sin nombre',
imageUrl: item.item_details.imagen,
quantity: item.quantity,
attributes: (item.variant?.attributes ?? []).map((attribute) => ({
attributes: item.item_details.attributes.map((attribute) => ({
label: attribute.name,
value: attribute.value,
value: attribute.value === null ? null : String(attribute.value),
})),
price: item.line_total,
originalPrice: null,