From 24c3756efd5203c2e23c678b6e6410de636a8b33 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sat, 14 Feb 2026 14:00:00 +0330 Subject: [PATCH] order history ui --- src/app/[name]/(Main)/order/history/page.tsx | 110 +++---------------- 1 file changed, 16 insertions(+), 94 deletions(-) diff --git a/src/app/[name]/(Main)/order/history/page.tsx b/src/app/[name]/(Main)/order/history/page.tsx index 8968dad..a4974c5 100644 --- a/src/app/[name]/(Main)/order/history/page.tsx +++ b/src/app/[name]/(Main)/order/history/page.tsx @@ -67,9 +67,10 @@ function OrdersIndex() { { id: 1, title: t('Tab.PreviousOrders'), icon: } ] - const firstTab = () => { + const renderOrders = (isActiveTab: boolean) => { + const emptyMessage = isActiveTab ? 'سفارش فعالی وجود ندارد' : 'سفارش قبلی وجود ندارد'; if (orders.length === 0) { - return [
سفارش فعالی وجود ندارد
]; + return [
{emptyMessage}
]; } return orders.map((order) => { @@ -83,6 +84,7 @@ function OrdersIndex() {
+ {!isActiveTab && }

#{order.orderNumber}

@@ -109,10 +111,10 @@ function OrdersIndex() { const itemTotalPrice = (item.totalPrice || item.unitPrice * item.quantity).toLocaleString('fa-IR'); return (
-
+
-
- ); - })} -
- -
-
- {formattedPrice} T -
-
- - - - -
- ) - }) - } - - const secondTab = () => { - if (orders.length === 0) { - return [
سفارش قبلی وجود ندارد
]; - } - - return orders.map((order) => { - const address = order.userAddress?.address || 'آدرس ثبت نشده'; - const formattedDate = formatDate(order.createdAt); - const formattedPrice = order.total.toLocaleString('fa-IR'); - const items: HistoryOrderItem[] = order.items || []; - - return ( -
-
-
-
- -

#{order.orderNumber}

-
-
- -

{t(`status.${order.status}`)}

-
-
-
- -

{address}

-
-
- -

{formattedDate}

-
-
- -
- -
- {items.map((item) => { - const imageUrl = getFoodImage(item.variant?.product.images); - const foodName = item.variant?.product.title || 'بدون نام'; - const itemTotalPrice = (item.totalPrice || item.unitPrice * item.quantity).toLocaleString('fa-IR'); - return ( -
-
- {foodName} -
-
-

- {foodName} -

-
- - {item.quantity}x - - - {itemTotalPrice} T - -
-
- {order.status === OrderStatus.COMPLETED && ( + {!isActiveTab && order.status === OrderStatus.COMPLETED && ( @@ -233,8 +150,13 @@ function OrdersIndex() {
- - + {isActiveTab ? ( + + + + ) : ( + + )}
) }) @@ -245,12 +167,12 @@ function OrdersIndex() {
{firstTab()}
} + viewRenderer={
{renderOrders(true)}
} title={categories[0].title} icon={categories[0].icon} /> {secondTab()}
} + viewRenderer={
{renderOrders(false)}
} title={categories[1].title} icon={categories[1].icon} />