Implement intercity document handling and rejection notes for contracts

This commit is contained in:
Marshal
2026-07-21 10:39:21 +00:00
parent 6f8456631c
commit 9ca4075c1e
3 changed files with 121 additions and 60 deletions

View File

@@ -447,6 +447,17 @@ export default function GlCreateBookingForm() {
if (!copyFromBooking || prefilled) return;
const lines = copyFromBooking.bookingContainers ?? [];
if (!lines.length) return;
// The booking stores a numeric sizeFt (20) but the contract scope — and the
// create payload the server validates — uses its own size strings ("20ft").
// Seed with the scope's string so the rebook payload matches what a fresh
// form entry would send.
const scopeSizeForFt = (sizeFt: number | null | undefined): string => {
if (sizeFt == null) return "";
return (
containerSizes.find((s) => parseInt(s, 10) === Number(sizeFt)) ??
`${sizeFt}ft`
);
};
setPrefilled(true);
setContainerLines(
lines.map((c) => {
@@ -466,7 +477,7 @@ export default function GlCreateBookingForm() {
}))
: Array.from({ length: qty }, emptyUnit);
return {
containerSize: String(c.containerType?.sizeFt ?? ""),
containerSize: scopeSizeForFt(c.containerType?.sizeFt),
quantity: String(qty),
hazardousQuantity: String(units.filter((u) => u.isHazardous).length),
reeferQuantity: String(units.filter((u) => u.isReefer).length),
@@ -475,7 +486,7 @@ export default function GlCreateBookingForm() {
};
}),
);
}, [copyFromBooking, prefilled]);
}, [copyFromBooking, prefilled, containerSizes]);
// Seed one shipment line per contracted size exactly once — same seeding the
// portal form does. Subsequent renders reuse the lines.