From f1e75832190a82650170f2657596f74de078aa6c Mon Sep 17 00:00:00 2001 From: NotII <46204250+NotII@users.noreply.github.com> Date: Sat, 26 Jul 2025 22:32:47 +0200 Subject: [PATCH] Add paidAt field and display to order details and table Introduces the optional 'paidAt' field to the Order interface and updates both the order details page and the order table to display the payment date. Also adds sorting by 'paidAt' in the order table and improves date formatting for both order and payment dates. --- app/dashboard/orders/[id]/page.tsx | 39 ++++++++++++++++++++++++++++++ components/tables/order-table.tsx | 18 ++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/app/dashboard/orders/[id]/page.tsx b/app/dashboard/orders/[id]/page.tsx index 7249968..177c8ad 100644 --- a/app/dashboard/orders/[id]/page.tsx +++ b/app/dashboard/orders/[id]/page.tsx @@ -53,6 +53,8 @@ interface Order { totalItemPrice: number; }>; totalPrice: number; + orderDate: Date; + paidAt?: Date; trackingNumber?: string; telegramUsername?: string; telegramBuyerId?: string; @@ -774,6 +776,43 @@ export default function OrderDetailsPage() { {/* Right Column - Actions and Status */}
+ {/* Order Information Card */} + + + Order Information + + +
+ +
+ {order?.orderDate ? new Date(order.orderDate).toLocaleDateString("en-GB", { + day: '2-digit', + month: 'short', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + hour12: false + }) : "-"} +
+
+ {order?.paidAt && ( +
+ +
+ {new Date(order.paidAt).toLocaleDateString("en-GB", { + day: '2-digit', + month: 'short', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + hour12: false + })} +
+
+ )} +
+
+ {/* Order Actions Card */} diff --git a/components/tables/order-table.tsx b/components/tables/order-table.tsx index e0d3643..fba0ee9 100644 --- a/components/tables/order-table.tsx +++ b/components/tables/order-table.tsx @@ -53,6 +53,7 @@ interface Order { status: string; totalPrice: number; orderDate: Date; + paidAt?: Date; telegramUsername?: string; telegramBuyerId?: string; underpaid?: boolean; @@ -61,7 +62,7 @@ interface Order { cryptoTotal?: number; } -type SortableColumns = "orderId" | "totalPrice" | "status" | "orderDate"; +type SortableColumns = "orderId" | "totalPrice" | "status" | "orderDate" | "paidAt"; interface StatusConfig { icon: React.ElementType; @@ -433,7 +434,10 @@ export default function OrderTable() { Status handleSort("orderDate")}> - Date + Order Date + + handleSort("paidAt")}> + Paid At Buyer Actions @@ -492,6 +496,16 @@ export default function OrderTable() { hour12: false })} + + {order.paidAt ? new Date(order.paidAt).toLocaleDateString("en-GB", { + day: '2-digit', + month: 'short', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + hour12: false + }) : "-"} + {order.telegramUsername ? `@${order.telegramUsername}` : "-"}