mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
fix train builder and consolidation
This commit is contained in:
@@ -25,10 +25,11 @@ import {
|
||||
} from "lucide-react";
|
||||
import type { Freight } from "@/types";
|
||||
import {
|
||||
calcWagons,
|
||||
type BookingFormInputValues,
|
||||
type BookingFormValues,
|
||||
} from "./schema";
|
||||
import { StepHeader } from "./shared";
|
||||
import { AlertBox, StepHeader } from "./shared";
|
||||
|
||||
export const REVIEW_STEP_TARGETS = {
|
||||
contract: 1,
|
||||
@@ -160,6 +161,12 @@ export function Step8Review({
|
||||
.join(", ")
|
||||
: "";
|
||||
|
||||
// 20ft containers must pair up (two per wagon) — an odd total blocks submit.
|
||||
const { hasOddUnit: hasOdd20ft, ft20Wagons: twentyFtCount } =
|
||||
values.cargoType === "container"
|
||||
? calcWagons(values.containers ?? [])
|
||||
: { hasOddUnit: false, ft20Wagons: 0 };
|
||||
|
||||
const isGeneralContract = values.bookingType === "general_contract";
|
||||
// Both one-time and general contracts take the bulk amount from the cargo step
|
||||
// (cargoWeight); general contracts no longer collect a per-route quantity.
|
||||
@@ -529,10 +536,27 @@ export function Step8Review({
|
||||
</Paper>
|
||||
|
||||
<Paper radius={20} p="lg" withBorder bg="white">
|
||||
<Text size="sm" c="dimmed" mb="md">
|
||||
Ready to submit. You'll review the unit rates before final
|
||||
submission.
|
||||
</Text>
|
||||
{hasOdd20ft ? (
|
||||
<Box mb="md">
|
||||
<AlertBox tone="error">
|
||||
<p className="font-semibold">
|
||||
Odd number of 20ft containers ({twentyFtCount})
|
||||
</p>
|
||||
<p className="mt-1 text-xs">
|
||||
20ft containers travel two per wagon, so they must be booked
|
||||
in even numbers. Go back to the cargo step and{" "}
|
||||
<strong>add one more 20ft container</strong> or{" "}
|
||||
<strong>remove one</strong> (e.g. {twentyFtCount + 1} or{" "}
|
||||
{twentyFtCount - 1} instead of {twentyFtCount}).
|
||||
</p>
|
||||
</AlertBox>
|
||||
</Box>
|
||||
) : (
|
||||
<Text size="sm" c="dimmed" mb="md">
|
||||
Ready to submit. You'll review the unit rates before final
|
||||
submission.
|
||||
</Text>
|
||||
)}
|
||||
<Stack gap="sm">
|
||||
<Button
|
||||
type="button"
|
||||
@@ -543,7 +567,7 @@ export function Step8Review({
|
||||
leftSection={<Send size={16} />}
|
||||
onClick={onSubmit}
|
||||
loading={submitPending}
|
||||
disabled={submitPending}
|
||||
disabled={submitPending || hasOdd20ft}
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user