diff --git a/apps/edr-freight-web/backoffice/src/pages/contracts/GlDjiboutiClearanceListPage.tsx b/apps/edr-freight-web/backoffice/src/pages/contracts/GlDjiboutiClearanceListPage.tsx index 733c882bb..afa15d8d1 100644 --- a/apps/edr-freight-web/backoffice/src/pages/contracts/GlDjiboutiClearanceListPage.tsx +++ b/apps/edr-freight-web/backoffice/src/pages/contracts/GlDjiboutiClearanceListPage.tsx @@ -1,40 +1,100 @@ +import { useState } from "react"; import { useNavigate } from "react-router-dom"; -import { Badge, Card, Group, Loader, Stack, Text } from "@mantine/core"; -import { ChevronRight, PackageCheck, Ship } from "lucide-react"; +import { + Badge, + Box, + Card, + Group, + Loader, + SegmentedControl, + Stack, + Text, +} from "@mantine/core"; +import { ChevronRight, FileSignature, PackageCheck, Ship } from "lucide-react"; import { PageContainer } from "@/components/page/PageContainer"; import { PageHeader } from "@/components/page/PageHeader"; import { useDjClearanceQueue } from "@/hooks/contracts/useContracts"; import { useBookingDjClearanceQueue } from "@/hooks/bookings/useBookings"; +type QueueTab = "contracts" | "shipments"; + +const prettyStatus = (s?: string | null) => + (s ?? "") + .toLowerCase() + .replace(/_/g, " ") + .replace(/^\w/, (c) => c.toUpperCase()); + +/** + * GL Djibouti clearance queues: + * - Contracts: ONE_TIME customs contracts in phased clearance (legacy flow). + * - Shipments: GENERAL-contract bookings in per-booking clearance awaiting a DJ + * action (DO collection after ET finalizes pre-clearance, RO for exports, + * loading milestones). Managed like the one-time flow, but per booking. + */ export default function GlDjiboutiClearanceListPage() { const navigate = useNavigate(); + const [tab, setTab] = useState("shipments"); const { data: contractQueue, isLoading: contractsLoading } = useDjClearanceQueue(); const { data: bookingQueue, isLoading: bookingsLoading } = useBookingDjClearanceQueue(); const contractItems = contractQueue?.items ?? []; const bookingItems = bookingQueue ?? []; + const isLoading = tab === "contracts" ? contractsLoading : bookingsLoading; return ( - - {contractsLoading || bookingsLoading ? ( - - - - ) : ( - - {contractItems.length === 0 && bookingItems.length === 0 ? ( - - No Djibouti customs work yet. - - ) : ( - <> - {contractItems.map((c) => ( + + + + setTab(v as QueueTab)} + radius="md" + data={[ + { + value: "shipments", + label: ( + + + Shipments + + {bookingItems.length} + + + ), + }, + { + value: "contracts", + label: ( + + + Contracts + + {contractItems.length} + + + ), + }, + ]} + /> + + {isLoading ? ( + + + + ) : tab === "contracts" ? ( + + {contractItems.length === 0 ? ( + + No Djibouti customs contracts yet. + + ) : ( + contractItems.map((c) => ( {c.reference} - {c.tradeDirection} · {c.status} + {c.tradeDirection} · {prettyStatus(c.status)} @@ -61,15 +121,24 @@ export default function GlDjiboutiClearanceListPage() { - ))} - {bookingItems.map((b) => ( + )) + )} + + ) : ( + + {bookingItems.length === 0 ? ( + + No shipment bookings awaiting a Djibouti action. + + ) : ( + bookingItems.map((b) => ( navigate(`/dashboard/clearance/${b.id}`)} + onClick={() => navigate(`/dashboard/gl-djibouti/clearance/${b.id}`)} > @@ -80,7 +149,8 @@ export default function GlDjiboutiClearanceListPage() {
{b.reference} - {b.tradeDirection} · {b.status} + {b.tradeDirection} · {prettyStatus(b.status)} + {b.company?.name ? ` · ${b.company.name}` : ""}
@@ -92,11 +162,11 @@ export default function GlDjiboutiClearanceListPage() {
- ))} - - )} -
- )} + )) + )} +
+ )} +
); }