mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 21:50:57 +00:00
Merge pull request #734 from Tria-plc/freight_feature/usermanagement
fix u=issue
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
TextInput,
|
||||
ThemeIcon,
|
||||
Title,
|
||||
Tooltip,
|
||||
} from "@mantine/core";
|
||||
import {
|
||||
AlertCircle,
|
||||
@@ -642,6 +643,20 @@ export default function GlCreateBookingForm() {
|
||||
});
|
||||
}, [isContainer, contract, containerLines, contractWithReturn]);
|
||||
|
||||
// 20ft containers ride two per wagon, so an odd total leaves one unpaired and
|
||||
// the booking can never be planned. The server rejects it too (the price
|
||||
// modal's `pairingErrors`), but that only lands after GL has filled the whole
|
||||
// form — mirror the customer portal (new-booking-form/schema.ts `calcWagons`)
|
||||
// and block it inline instead. Size strings arrive as "20ft" from the contract
|
||||
// scope but as a bare "20" from the rebook seed, so match on the leading digits.
|
||||
const ft20Total = useMemo(() => {
|
||||
if (!isContainer) return 0;
|
||||
return containerLines
|
||||
.filter((l) => parseInt(l.containerSize, 10) === 20)
|
||||
.reduce((sum, l) => sum + Number(l.quantity || 0), 0);
|
||||
}, [isContainer, containerLines]);
|
||||
const hasOdd20ft = ft20Total % 2 === 1;
|
||||
|
||||
const bulkUom = contract ? bulkUnitOfMeasure(contract) : "PER_TON";
|
||||
|
||||
const bulkErrors = useMemo<BulkErrors>(() => {
|
||||
@@ -688,7 +703,7 @@ export default function GlCreateBookingForm() {
|
||||
)
|
||||
: !bulkErrors.quantity && !bulkErrors.hazardous && !bulkErrors.reefer;
|
||||
|
||||
const formValid = cargoValid && !dateError && !routeError;
|
||||
const formValid = cargoValid && !hasOdd20ft && !dateError && !routeError;
|
||||
|
||||
/** The create-booking DTO from the current form state — shared by the
|
||||
* authoritative price preview and the actual submit so what GL confirms is
|
||||
@@ -1286,6 +1301,21 @@ export default function GlCreateBookingForm() {
|
||||
</Box>
|
||||
))
|
||||
)}
|
||||
|
||||
{hasOdd20ft ? (
|
||||
<Alert
|
||||
color="red"
|
||||
variant="light"
|
||||
radius="md"
|
||||
icon={<AlertCircle size={16} />}
|
||||
title={`Odd number of 20ft containers (${ft20Total})`}
|
||||
>
|
||||
20ft containers travel two per wagon, so they must be booked in
|
||||
even numbers. Add one more 20ft container or remove one (e.g.
|
||||
book {ft20Total + 1} or {ft20Total - 1} instead of {ft20Total})
|
||||
— the booking cannot be created with an unpaired 20ft container.
|
||||
</Alert>
|
||||
) : null}
|
||||
</Stack>
|
||||
</StepCard>
|
||||
) : (
|
||||
@@ -1530,14 +1560,27 @@ export default function GlCreateBookingForm() {
|
||||
</Alert>
|
||||
) : null}
|
||||
<Group justify="flex-end">
|
||||
<Button
|
||||
color="edr-green"
|
||||
radius="md"
|
||||
leftSection={<Receipt size={16} />}
|
||||
onClick={openPriceModal}
|
||||
<Tooltip
|
||||
label={`Book an even number of 20ft containers — ${ft20Total} is odd and would leave one unpaired.`}
|
||||
withArrow
|
||||
disabled={!hasOdd20ft}
|
||||
>
|
||||
Review price & book
|
||||
</Button>
|
||||
{/* Mantine tooltips get no pointer events from a disabled button,
|
||||
so the wrapper carries the hover target. */}
|
||||
<Box>
|
||||
<Button
|
||||
color="edr-green"
|
||||
radius="md"
|
||||
leftSection={<Receipt size={16} />}
|
||||
onClick={openPriceModal}
|
||||
// Same hard block the customer portal applies at review time —
|
||||
// an unpaired 20ft can never be planned onto a wagon.
|
||||
disabled={hasOdd20ft}
|
||||
>
|
||||
Review price & book
|
||||
</Button>
|
||||
</Box>
|
||||
</Tooltip>
|
||||
</Group>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -36,7 +36,9 @@ export function PinWagonsForm({
|
||||
autoFillOnMount?: boolean;
|
||||
}) {
|
||||
const originYardId = schedule.originStation?.id;
|
||||
const slots = schedule.trainSet?.wagons ?? [];
|
||||
// Consist-only rows are the built train's coupled-but-empty wagons — display
|
||||
// entries with no TrainSetWagon slot behind them, so nothing can be pinned.
|
||||
const slots = (schedule.trainSet?.wagons ?? []).filter((w) => !w.consistOnly);
|
||||
const [assignments, setAssignments] = useState<Record<string, string>>({});
|
||||
|
||||
const wagonOptionsByType = useMemo(() => {
|
||||
|
||||
@@ -359,7 +359,9 @@ function WagonCar({
|
||||
|
||||
{isEmpty ? (
|
||||
<Text size="xs" c="dimmed">
|
||||
Empty slot — available for allocation.
|
||||
{wagon.consistOnly
|
||||
? "Empty wagon — coupled on the train, no load planned."
|
||||
: "Empty slot — available for allocation."}
|
||||
</Text>
|
||||
) : (
|
||||
<Stack gap={6}>
|
||||
|
||||
@@ -167,9 +167,9 @@ export const WagonCard = ({
|
||||
<TrainFront size={18} />
|
||||
</ThemeIcon>
|
||||
<Text size="sm" c="dimmed">
|
||||
Empty slot
|
||||
{wagon.consistOnly ? "Empty wagon — coupled on the train" : "Empty slot"}
|
||||
</Text>
|
||||
{!isDispatched ? (
|
||||
{!isDispatched && !wagon.consistOnly ? (
|
||||
<Button
|
||||
variant="subtle"
|
||||
color="gray"
|
||||
|
||||
Reference in New Issue
Block a user