"use client"; import { ReusableTable, ActionButtons } from "../../UI"; import { ORDER_STATUS_MAP } from "../OrderDetailModel"; import type { TableColumn } from "@/src/types/models"; import type { ArchivedOrder } from "@/src/types/order"; function fmtAmount(n?: string | number | null): string { if (n == null) return "—"; const num = typeof n === "string" ? parseFloat(n) : n; if (Number.isNaN(num)) return "—"; return `${num.toFixed(2)} SAR`; } interface ArchivedOrderTableProps { orders: ArchivedOrder[]; loading: boolean; search: string; page: number; pages: number; onView: (order: ArchivedOrder) => void; onPageChange: (p: number) => void; } export function ArchivedOrderTable({ orders, loading, search, page, pages, onView, onPageChange }: ArchivedOrderTableProps) { const columns: TableColumn[] = [ { key: "shipmentNumber", header: "رقم الشحنة #", width: "1.6fr", render: (o) => {o.shipmentNumber}, }, { key: "recipient", header: "المستلم", width: "1.6fr", render: (o) => (

{o.recipientName}

{o.recipientPhone}

), }, { key: "amount", header: "الكمية", width: "1fr", render: (o) => {fmtAmount(o.subTotal)}, }, { key: "status", header: "الحالة", width: "1fr", render: (o) => { const s = ORDER_STATUS_MAP[o.currentStatus] ?? ORDER_STATUS_MAP.Created; return ( {s.label} ); }, }, ]; return ( onView(o)} />} /> ); }