feat: add truck arrival/departure times to import trucks page

Show per-truck warehouse gate arrival (arrivedAt) and departure
(departedAt) timestamps on the Import Trucks page, enabling staff to see
when each truck entered and exited the warehouse. Times displayed in local
format; EDR and customer trucks both supported.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Hagernesh
2026-07-30 06:34:47 +00:00
parent 541f2a11c1
commit 4cb4d177d9

View File

@@ -50,11 +50,14 @@ import type { ImportUnloadedItem } from "@/types/warehouse";
* would be several hundred requests for rows nobody opened.
*/
const COLS = 9;
const COLS = 11;
const money = (amount: number, currency: string) =>
`${Number(amount).toLocaleString(undefined, { maximumFractionDigits: 2 })} ${currency === "ETB" ? "ETB" : currency}`;
const formatTime = (iso: string | null | undefined) =>
iso ? new Date(iso).toLocaleString() : "—";
interface BookingGroup {
bookingId: string;
bookingReference: string;
@@ -103,6 +106,8 @@ interface TruckRow {
demurrage: number;
storage: number;
vehicleId: string | null;
arrivedAt: string | null;
departedAt: string | null;
}
/**
@@ -185,6 +190,8 @@ function TruckRows({ group }: { group: BookingGroup }) {
truckType: t.truckType,
containers,
vehicleId: t.vehicleId,
arrivedAt: t.arrivedAt,
departedAt: t.departedAt,
...costsFor(containers),
};
};
@@ -197,6 +204,8 @@ function TruckRows({ group }: { group: BookingGroup }) {
truckType: t.truckType,
containers,
vehicleId: null,
arrivedAt: t.arrivedAt ?? null,
departedAt: t.departedAt ?? null,
...costsFor(containers),
};
};
@@ -283,6 +292,12 @@ function TruckRows({ group }: { group: BookingGroup }) {
<Table.Td>
<Text size="sm">{t.containers.length ? t.containers.join(", ") : "Bulk"}</Text>
</Table.Td>
<Table.Td>
<Text size="xs">{formatTime(t.arrivedAt)}</Text>
</Table.Td>
<Table.Td>
<Text size="xs">{formatTime(t.departedAt)}</Text>
</Table.Td>
<Table.Td>{formatNumber(t.weight)}</Table.Td>
<Table.Td>{money(t.demurrage, feeCurrency)}</Table.Td>
<Table.Td>{money(t.storage, feeCurrency)}</Table.Td>
@@ -431,6 +446,8 @@ export default function ImportTrucksPage() {
<Table.Th>Plate</Table.Th>
<Table.Th>Type</Table.Th>
<Table.Th>Containers</Table.Th>
<Table.Th>Truck Arrival</Table.Th>
<Table.Th>Truck Leaving</Table.Th>
<Table.Th>Weight</Table.Th>
<Table.Th>Demurrage</Table.Th>
<Table.Th>Storage</Table.Th>