From eb9ecfa76044800871b1b3511721527583bc1505 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sat, 6 Dec 2025 12:24:16 +0330 Subject: [PATCH] history orders image food --- src/app/[name]/(Main)/order/history/page.tsx | 12 +++++++++--- src/app/[name]/(Main)/order/history/types/Types.ts | 2 +- src/components/tab/PerformantTabRenderer.tsx | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/[name]/(Main)/order/history/page.tsx b/src/app/[name]/(Main)/order/history/page.tsx index aea4c1f..05820b4 100644 --- a/src/app/[name]/(Main)/order/history/page.tsx +++ b/src/app/[name]/(Main)/order/history/page.tsx @@ -16,11 +16,17 @@ import { HistoryOrderItem } from './types/Types'; const fallbackImage = '/assets/images/food-preview.png'; -const getFoodImage = (images: string | null | undefined): string => { - if (!images || typeof images !== 'string') { +const getFoodImage = (images: string[] | string | null | undefined): string => { + if (!images) { return fallbackImage; } - return images; + if (Array.isArray(images)) { + return images.length > 0 ? images[0] : fallbackImage; + } + if (typeof images === 'string') { + return images; + } + return fallbackImage; }; const formatDate = (dateString: string): string => { diff --git a/src/app/[name]/(Main)/order/history/types/Types.ts b/src/app/[name]/(Main)/order/history/types/Types.ts index 2eb1af5..9173dd0 100644 --- a/src/app/[name]/(Main)/order/history/types/Types.ts +++ b/src/app/[name]/(Main)/order/history/types/Types.ts @@ -117,7 +117,7 @@ export interface HistoryOrderFood { stock: number; stockDefault: number; isActive: boolean; - images: string | null; + images: string[] | null; inPlaceServe: boolean; pickupServe: boolean; rate: number; diff --git a/src/components/tab/PerformantTabRenderer.tsx b/src/components/tab/PerformantTabRenderer.tsx index 57b500b..cb2ec99 100644 --- a/src/components/tab/PerformantTabRenderer.tsx +++ b/src/components/tab/PerformantTabRenderer.tsx @@ -42,7 +42,7 @@ function PerformantTabRenderer({ children, rowHeight = 100, ...rest }: Props) {