import { useMemo, useState } from "react"; import { ArrowRight, Building2, Clock, Eye, LayoutGrid, List, MapPin, MoreHorizontal, Pencil, Plus, Search, Train, Trash2, Truck, } from "lucide-react"; import Breadcrumbs from "@/components/Breadcrumbs"; import NewShipmentPage from "./NewShipmentPage"; import DeleteShipmentDialog from "./DeleteShipmentDialog"; import { shipments, type Shipment, type ShipmentMode, type ShipmentStatus, } from "./shipments.mock"; import { Button, Card, CardHeader, CardTitle, CardDescription, CardContent, Input, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, } from "@edr/ui-common"; type FilterValue = "All" | ShipmentStatus; type ViewMode = "grid" | "table"; const FILTERS: FilterValue[] = ["All", "In Transit", "Delivered", "Delayed"]; export default function TrackingPage() { const [filter, setFilter] = useState("All"); const [query, setQuery] = useState(""); const [view, setView] = useState("grid"); const filtered = useMemo(() => { const q = query.trim().toLowerCase(); return shipments.filter((s) => { if (filter !== "All" && s.status !== filter) return false; if (!q) return true; return ( s.reference.toLowerCase().includes(q) || s.consignmentReference.toLowerCase().includes(q) || s.bookingReference.toLowerCase().includes(q) || s.customer.toLowerCase().includes(q) || s.originStation.toLowerCase().includes(q) || s.destinationStation.toLowerCase().includes(q) || s.currentLocation.toLowerCase().includes(q) ); }); }, [filter, query]); return (

Shipment Tracking

Real-time cargo and shipment monitoring.

setQuery(e.target.value)} placeholder="Search shipments..." className="pl-8!" />
{FILTERS.map((f) => { const isActive = f === filter; const count = f === "All" ? shipments.length : shipments.filter((s) => s.status === f).length; return ( ); })}
setView("grid")} label="Grid view" > Grid setView("table")} label="Table view" > Table
{filtered.length === 0 ? (

No shipments match your filters.

) : view === "grid" ? (
{filtered.map((shipment) => ( ))}
) : ( )}
); } function ViewToggleButton({ active, onClick, label, children, }: { active: boolean; onClick: () => void; label: string; children: React.ReactNode; }) { return ( ); } function ShipmentCard({ shipment }: { shipment: Shipment }) { return (
{shipment.reference} Consignment {shipment.consignmentReference}

From

{shipment.originStation}

To

{shipment.destinationStation}

Progress {shipment.progress}%
{shipment.customer}
{shipment.mode}
{shipment.currentLocation}
Updated {shipment.lastUpdate} ยท ETA {shipment.eta}
e.stopPropagation()}> View e.preventDefault()}> Edit e.preventDefault()} variant="destructive"> Remove
); } function ShipmentTable({ shipments: rows }: { shipments: Shipment[] }) { return (
Shipment List All shipments and their current status.
{rows.map((shipment) => ( ))}
Shipment Booking Route Mode Status Progress Current Location ETA Actions

{shipment.reference}

{shipment.customer}

{shipment.bookingReference}
{shipment.originStation} {shipment.destinationStation}
{shipment.mode}
{shipment.progress}%
{shipment.currentLocation}
{shipment.eta}
e.stopPropagation()}> View e.preventDefault()}> Edit e.preventDefault()} variant="destructive"> Remove
); } function ModeIcon({ mode }: { mode: ShipmentMode }) { if (mode === "rail") return ; if (mode === "truck") return ; return ; } function StatusBadge({ status }: { status: ShipmentStatus }) { const styles: Record = { "In Transit": "bg-indigo-100 text-indigo-700", Delivered: "bg-emerald-100 text-emerald-700", Delayed: "bg-red-100 text-red-700", }; return ( {status} ); }