enhance booking window logic to support overnight desk configurations and update related UI components

This commit is contained in:
Marshal
2026-07-05 21:29:09 +00:00
parent 3485a7d63d
commit caa8397563
5 changed files with 83 additions and 36 deletions

View File

@@ -120,7 +120,7 @@ export function GlClearanceUploadModal({
/>
) : (
<DateInput
label="Vessel departure date (optional)"
label="Vessel arrival date (optional)"
value={vesselDate}
onChange={(v) => setVesselDate(v ? new Date(v) : null)}
size="sm"

View File

@@ -119,7 +119,9 @@ export default function BookingWindowSettingsModal({
const canEdit = schedule?.windowPhase === "PRE_WINDOW";
const is24h =
form != null && form.windowOpenHour === form.windowCloseHour;
const closeBeforeOpen =
// Close < open is a valid OVERNIGHT desk (e.g. 08:00 → 07:00 next morning),
// not an error — the engine wraps it across midnight.
const isOvernight =
form != null && form.windowCloseHour < form.windowOpenHour;
const reopenSummary = useMemo(() => {
@@ -156,15 +158,6 @@ export default function BookingWindowSettingsModal({
});
return;
}
if (closeBeforeOpen) {
toast({
title: "Close hour must be on or after the open hour",
description: "Set them equal for a 24-hour desk.",
variant: "destructive",
});
return;
}
const payload: UpdateScheduleWindowRulePayload = {
windowOpenHour: form.windowOpenHour,
windowCloseHour: form.windowCloseHour,
@@ -282,10 +275,15 @@ export default function BookingWindowSettingsModal({
}
allowDeselect={false}
comboboxProps={{ withinPortal: true }}
error={closeBeforeOpen ? "Must be ≥ open hour" : undefined}
disabled={isExport}
/>
</Group>
{isOvernight && !is24h ? (
<Text size="xs" c="dimmed" mt={4}>
Overnight desk opens {form.windowOpenHour}:00 and runs past
midnight, closing {form.windowCloseHour}:00 the next morning.
</Text>
) : null}
<Switch
mt="sm"
size="sm"
@@ -394,11 +392,7 @@ export default function BookingWindowSettingsModal({
<Button variant="default" onClick={onClose} disabled={save.isPending}>
Cancel
</Button>
<Button
onClick={handleSave}
loading={save.isPending}
disabled={closeBeforeOpen}
>
<Button onClick={handleSave} loading={save.isPending}>
Save settings
</Button>
</Group>