mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 21:50:57 +00:00
Merge pull request #584 from Tria-plc/freight_feature/usermanagement
Enhance bulk booking handling and wagon capacity calculations across …
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user