Implement clearance-first booking flow and completion process for customs contracts

This commit is contained in:
Marshal
2026-07-10 21:51:59 +00:00
parent 9ed473c309
commit 1121e9ce82
19 changed files with 482 additions and 106 deletions

View File

@@ -198,18 +198,17 @@ export default function GlCreateBookingForm() {
);
// Next future window across all routes, used for the "next window" notice —
// the train dispatching soonest among those not yet open, matching the
// departure-date ordering of the window cards.
// the next moment booking OPENS (chronological), which may belong to a
// later-departing train. Departure-first ordering here named the soonest
// train's later opening as "next" while another lane opened earlier.
const nextWindow = useMemo(() => {
const now = Date.now();
return (bookingWindows ?? [])
.filter((w) => w.windowOpensAt && new Date(w.windowOpensAt).getTime() > now)
.sort((a, b) => {
const da = a.departureDate ? new Date(a.departureDate).getTime() : Infinity;
const db = b.departureDate ? new Date(b.departureDate).getTime() : Infinity;
if (da !== db) return da - db;
return new Date(a.windowOpensAt!).getTime() - new Date(b.windowOpensAt!).getTime();
})[0];
.sort(
(a, b) =>
new Date(a.windowOpensAt!).getTime() - new Date(b.windowOpensAt!).getTime(),
)[0];
}, [bookingWindows]);
const [scheduledDate, setScheduledDate] = useState("");