mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 01:48:12 +00:00
enhance shipment form and booking process
This commit is contained in:
@@ -287,6 +287,8 @@ export type SegmentStripBooking = {
|
||||
destinationYardId?: string | null;
|
||||
tradeDirection?: string | null;
|
||||
wagonsRequired?: number | null;
|
||||
/** GROSS tons (cargo + tare of the booking's wagons), as the API sends it. */
|
||||
weightTons?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -300,10 +302,13 @@ export function SegmentOccupancyStrip({
|
||||
stops,
|
||||
bookings,
|
||||
maxWagons,
|
||||
maxGrossTons,
|
||||
}: {
|
||||
stops: Array<{ yardId: string; label: string }>;
|
||||
bookings: SegmentStripBooking[];
|
||||
maxWagons?: number | null;
|
||||
/** Loco pull ceiling incl. tolerance — per-leg gross is measured against it. */
|
||||
maxGrossTons?: number | null;
|
||||
}) {
|
||||
if (stops.length < 2) return null;
|
||||
const lastIdx = stops.length - 1;
|
||||
@@ -312,6 +317,7 @@ export function SegmentOccupancyStrip({
|
||||
const segments = stops.slice(0, -1).map((stop, edge) => {
|
||||
let cargo = 0;
|
||||
let intercity = 0;
|
||||
let grossTons = 0;
|
||||
for (const b of bookings) {
|
||||
const from = (b.originYardId ? indexOf.get(b.originYardId) : undefined) ?? 0;
|
||||
const to =
|
||||
@@ -322,8 +328,15 @@ export function SegmentOccupancyStrip({
|
||||
const wagons = Number(b.wagonsRequired) || 1;
|
||||
if (b.tradeDirection === "DOMESTIC") intercity += wagons;
|
||||
else cargo += wagons;
|
||||
grossTons += Number(b.weightTons) || 0;
|
||||
}
|
||||
return { from: stop, to: stops[edge + 1], cargo, intercity };
|
||||
return {
|
||||
from: stop,
|
||||
to: stops[edge + 1],
|
||||
cargo,
|
||||
intercity,
|
||||
grossTons: Math.round(grossTons * 10) / 10,
|
||||
};
|
||||
});
|
||||
|
||||
const cap = Number(maxWagons) || null;
|
||||
@@ -393,6 +406,22 @@ export function SegmentOccupancyStrip({
|
||||
</Text>
|
||||
) : null}
|
||||
</Text>
|
||||
{seg.grossTons > 0 ? (
|
||||
<Text
|
||||
size="xs"
|
||||
ta="center"
|
||||
fw={600}
|
||||
c={
|
||||
maxGrossTons != null && seg.grossTons > maxGrossTons
|
||||
? "red.7"
|
||||
: "dimmed"
|
||||
}
|
||||
style={{ whiteSpace: "nowrap" }}
|
||||
>
|
||||
{seg.grossTons}
|
||||
{maxGrossTons != null ? ` / ${maxGrossTons}` : ""} T gross
|
||||
</Text>
|
||||
) : null}
|
||||
</Stack>
|
||||
{i === segments.length - 1 ? (
|
||||
<Stack gap={2} align="center" justify="flex-end" style={{ minWidth: 0 }}>
|
||||
|
||||
Reference in New Issue
Block a user