Merge pull request #584 from Tria-plc/freight_feature/usermanagement

Enhance bulk booking handling and wagon capacity calculations across …
This commit is contained in:
marshal
2026-07-09 18:31:00 +03:00
committed by GitHub
11 changed files with 278 additions and 32 deletions

View File

@@ -207,9 +207,9 @@ function RankedCard({
{/* Wagons */}
<Group gap={4} wrap="nowrap" w={58} justify="flex-end">
<TrainFront size={13} color={cardVar("gray", 6)} />
{/* <Text fw={700} size="sm">
<Text fw={700} size="sm">
{booking.wagons}w
</Text> */}
</Text>
</Group>
{/* State chip / pay countdown */}
@@ -295,9 +295,9 @@ export function PriorityTrackingTab({ data, bookings }: Props) {
}, [bookings]);
const scoreMax = useMemo(() => maxScore(ranked), [ranked]);
// maxWagons is not on the board DTO (capacity is length/weight-based), so the
// capacity line shows the wagons currently committed rather than a hard cap.
const maxWagons: number | null = null;
// Wagon-slot cap from the board DTO (derived from train length and the
// shortest wagon type); null on legacy rows without a computable cap.
const maxWagons: number | null = data.capacity.maxWagons ?? null;
// Split the ranking at the capacity line: cumulative wagons of slot-occupying
// bookings (allocated + selected + paid-waiting) up to the train's wagon cap.
@@ -431,23 +431,31 @@ export function PriorityTrackingTab({ data, bookings }: Props) {
<Text size="xs" fw={700}>
{data.capacity.allocatedWagons} allocated ·{" "}
{capUsed} in batch
{maxWagons != null ? ` · ${maxWagons} max` : ""}
</Text>
</Group>
{/* Scale against the real wagon cap when the DTO carries one; fall back
to the in-batch total on legacy rows without a computable cap. */}
<Progress.Root size="lg" radius="xl">
<Progress.Section
value={
capUsed > 0
? Math.min(100, (data.capacity.allocatedWagons / capUsed) * 100)
(maxWagons ?? capUsed) > 0
? Math.min(
100,
(data.capacity.allocatedWagons / (maxWagons ?? capUsed)) * 100,
)
: 0
}
color="edr-green"
/>
<Progress.Section
value={
capUsed > 0
(maxWagons ?? capUsed) > 0
? Math.min(
100,
((capUsed - data.capacity.allocatedWagons) / capUsed) * 100,
((capUsed - data.capacity.allocatedWagons) /
(maxWagons ?? capUsed)) *
100,
)
: 0
}