mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +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
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
AlertTriangle,
|
||||
ArrowLeft,
|
||||
ArrowLeftRight,
|
||||
// Boxes,
|
||||
Boxes,
|
||||
CalendarDays,
|
||||
CheckCircle2,
|
||||
ClipboardCheck,
|
||||
@@ -348,9 +348,9 @@ const BOOKING_COLUMNS: ColumnDef<BatchBoardBookingDetail>[] = [
|
||||
const b = row.original;
|
||||
return (
|
||||
<Group gap={4} wrap="nowrap">
|
||||
{/* <Badge variant="default" radius="sm" size="sm">
|
||||
<Badge variant="default" radius="sm" size="sm">
|
||||
{b.wagons}w
|
||||
</Badge> */}
|
||||
</Badge>
|
||||
<Badge variant="default" radius="sm" size="sm">
|
||||
{fmtTons(b.weightTons)}
|
||||
</Badge>
|
||||
@@ -890,14 +890,14 @@ export default function BatchScheduleDetailPage() {
|
||||
|
||||
<KpiStrip
|
||||
items={[
|
||||
// {
|
||||
// label: "Allocated wagons",
|
||||
// value: data.capacity.maxWagons
|
||||
// ? `${data.capacity.allocatedWagons} / ${data.capacity.maxWagons}`
|
||||
// : data.capacity.allocatedWagons,
|
||||
// hint: "on this train",
|
||||
// icon: Boxes,
|
||||
// },
|
||||
{
|
||||
label: "Allocated wagons",
|
||||
value: data.capacity.maxWagons
|
||||
? `${data.capacity.allocatedWagons} / ${data.capacity.maxWagons}`
|
||||
: data.capacity.allocatedWagons,
|
||||
hint: "on this train",
|
||||
icon: Boxes,
|
||||
},
|
||||
{
|
||||
label: "Train length",
|
||||
value: data.capacity.maxLengthMeters
|
||||
@@ -1111,7 +1111,7 @@ export default function BatchScheduleDetailPage() {
|
||||
<TrainCompositionDiagram
|
||||
locomotive={scheduleDetailQuery.data.trainSet?.locomotive}
|
||||
wagons={scheduleDetailQuery.data.trainSet?.wagons ?? []}
|
||||
freightType="CONTAINER"
|
||||
freightType={scheduleDetailQuery.data.freightType ?? null}
|
||||
trainNumber={scheduleDetailQuery.data.trainNumber}
|
||||
totalLengthMeters={
|
||||
scheduleDetailQuery.data.trainSet?.totalLengthMeters
|
||||
@@ -1133,7 +1133,7 @@ export default function BatchScheduleDetailPage() {
|
||||
<TrainConsistView
|
||||
scheduleDetail={scheduleDetailQuery.data}
|
||||
scheduleId={scheduleId ?? ""}
|
||||
maxWagons={53}
|
||||
maxWagons={data.capacity.maxWagons ?? 53}
|
||||
highlightBookingId={selectedBookingId}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user