feat(purchase-detail): update item details structure and handle null values in mapping
This commit is contained in:
@@ -24,7 +24,7 @@ export interface PurchaseSummaryResponse extends PurchaseStatusResponse {
|
|||||||
|
|
||||||
export interface PurchaseDetailAttributeResponse {
|
export interface PurchaseDetailAttributeResponse {
|
||||||
name: string;
|
name: string;
|
||||||
value: string | null;
|
value: string | number | boolean | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PurchaseDetailItemResponse {
|
export interface PurchaseDetailItemResponse {
|
||||||
@@ -32,16 +32,15 @@ export interface PurchaseDetailItemResponse {
|
|||||||
quantity: number;
|
quantity: number;
|
||||||
unit_price: string;
|
unit_price: string;
|
||||||
line_total: string;
|
line_total: string;
|
||||||
product: {
|
source_catalog_item_id: number | null;
|
||||||
id: number;
|
source_variant_id: number | null;
|
||||||
|
item_details: {
|
||||||
nombre: string;
|
nombre: string;
|
||||||
|
descripcion: string | null;
|
||||||
slug: string;
|
slug: string;
|
||||||
imagen: string | null;
|
imagen: string | null;
|
||||||
} | null;
|
|
||||||
variant: {
|
|
||||||
id: number;
|
|
||||||
attributes: PurchaseDetailAttributeResponse[];
|
attributes: PurchaseDetailAttributeResponse[];
|
||||||
} | null;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PurchaseDetailResponse extends PurchaseStatusResponse {
|
export interface PurchaseDetailResponse extends PurchaseStatusResponse {
|
||||||
@@ -52,10 +51,11 @@ export interface PurchaseDetailResponse extends PurchaseStatusResponse {
|
|||||||
created_at: string | null;
|
created_at: string | null;
|
||||||
payment_method: string | null;
|
payment_method: string | null;
|
||||||
dni: string | null;
|
dni: string | null;
|
||||||
|
transfer_payer_dni: string | null;
|
||||||
telefono: string | null;
|
telefono: string | null;
|
||||||
nombre_apellido: string | null;
|
nombre_apellido: string | null;
|
||||||
email: string | null;
|
email: string | null;
|
||||||
items_source: 'purchase' | 'cart' | null;
|
items_source: 'purchase';
|
||||||
items: PurchaseDetailItemResponse[];
|
items: PurchaseDetailItemResponse[];
|
||||||
subtotal: string;
|
subtotal: string;
|
||||||
total: string;
|
total: string;
|
||||||
|
|||||||
@@ -79,12 +79,12 @@ export class PurchaseDetailPage implements OnInit {
|
|||||||
private mapItems(purchase: PurchaseDetailResponse): PurchaseItemViewModel[] {
|
private mapItems(purchase: PurchaseDetailResponse): PurchaseItemViewModel[] {
|
||||||
return purchase.items.map((item) => ({
|
return purchase.items.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
title: item.product?.nombre ?? 'Producto sin nombre',
|
title: item.item_details.nombre || 'Producto sin nombre',
|
||||||
imageUrl: item.product?.imagen ?? null,
|
imageUrl: item.item_details.imagen,
|
||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
attributes: (item.variant?.attributes ?? []).map((attribute) => ({
|
attributes: item.item_details.attributes.map((attribute) => ({
|
||||||
label: attribute.name,
|
label: attribute.name,
|
||||||
value: attribute.value,
|
value: attribute.value === null ? null : String(attribute.value),
|
||||||
})),
|
})),
|
||||||
price: item.line_total,
|
price: item.line_total,
|
||||||
originalPrice: null,
|
originalPrice: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user