import type { Freight } from "@edr/types";
import { Table, type TableColumn } from "@edr/ui-common";

export interface ConsignmentTableProps {
  consignments: Freight.IConsignment[];
}

const columns: TableColumn<Freight.IConsignment>[] = [
  { key: "trackingNumber", header: "Tracking #" },
  { key: "cargoType", header: "Cargo" },
  { key: "status", header: "Status" },
  { key: "originStation", header: "Origin" },
  { key: "destinationStation", header: "Destination" },
  {
    key: "weightKg",
    header: "Weight (kg)",
    render: (row) => row.weightKg.toFixed(2),
  },
];

const ConsignmentTable = ({ consignments }: ConsignmentTableProps) => (
  <Table
    columns={columns}
    data={consignments}
    rowKey={(row) => row.id}
    emptyMessage="No consignments yet"
  />
);

export default ConsignmentTable;
