"use client"; import { ReusableTable } from "@/src/Components/UI"; import { TRIP_STATUS_MAP } from "@/src/types/trip"; import type { TableColumn } from "@/src/types/models"; import type { Trip } from "@/src/types/trip"; function fmtDate(iso?: string | null): string { if (!iso) return "—"; return new Date(iso).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }); } interface ArchivedTripTableProps { trips: Trip[]; loading: boolean; search: string; page: number; pages: number; onView: (trip: Trip) => void; onPageChange: (p: number) => void; } export function ArchivedTripTable({ trips, loading, search, page, pages, onView, onPageChange }: ArchivedTripTableProps) { const columns: TableColumn[] = [ { key: "title", header: "الرحلة", width: "2fr", render: (t) => (

{t.title}

{t.tripNumber}

), }, { key: "status", header: "الحالة", width: "1.5fr", render: (t) => { const s = TRIP_STATUS_MAP[t.status]; return ( {s.label} ); }, }, { key: "start", header: "تاريخ البداية", width: "1fr", align: "center", render: (t) => fmtDate(t.startTime) }, { key: "end", header: "تاريخ الانتهاء", width: "1fr", align: "center", render: (t) => fmtDate(t.endTime) }, { key: "cash", header: "المبلغ المحصل", width: "1fr", align: "center", render: (t) => ( {t.totalCashCollected != null ? `${Number(t.totalCashCollected).toLocaleString("en-US")} SAR` : "—"} ), }, ]; return ( ); }