mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 17:10:56 +00:00
feat(train-scheduling): add showWagonStat prop to control wagon stats visibility
This commit is contained in:
@@ -18,6 +18,8 @@ interface TrainConsistViewProps {
|
||||
scheduleDetail: TrainScheduleDetail;
|
||||
scheduleId: string;
|
||||
maxWagons: number;
|
||||
/** Hide the consist-wide Wagons stat tile (dispatch shows leg capacity instead). */
|
||||
showWagonStat?: boolean;
|
||||
/** Booking id selected in the side panel — highlights its wagons in the consist. */
|
||||
highlightBookingId?: string | null;
|
||||
}
|
||||
@@ -45,6 +47,7 @@ export const TrainConsistView = ({
|
||||
scheduleDetail,
|
||||
scheduleId,
|
||||
maxWagons,
|
||||
showWagonStat = true,
|
||||
highlightBookingId,
|
||||
}: TrainConsistViewProps) => {
|
||||
const [selectedWagonId, setSelectedWagonId] = useState<string | null>(null);
|
||||
@@ -172,6 +175,7 @@ export const TrainConsistView = ({
|
||||
lengthMax={lengthMax}
|
||||
wagonCount={wagonsUsed}
|
||||
wagonMax={maxWagons}
|
||||
showWagons={showWagonStat}
|
||||
/>
|
||||
|
||||
{/* Consist panel */}
|
||||
|
||||
@@ -9,6 +9,12 @@ interface TrainStatsBarProps {
|
||||
lengthMax: number | null;
|
||||
wagonCount: number;
|
||||
wagonMax: number;
|
||||
/**
|
||||
* The wagon tile is a consist-wide count, which reads as wrong on a
|
||||
* multi-leg schedule where per-leg capacity is the real number. Dispatch
|
||||
* hides it (leg capacity is shown there instead); the batch board keeps it.
|
||||
*/
|
||||
showWagons?: boolean;
|
||||
}
|
||||
|
||||
function pctColor(pct: number) {
|
||||
@@ -83,6 +89,7 @@ export const TrainStatsBar = ({
|
||||
lengthMax,
|
||||
wagonCount,
|
||||
wagonMax,
|
||||
showWagons = true,
|
||||
}: TrainStatsBarProps) => {
|
||||
const weightPct = weightMax ? (weightUsed / weightMax) * 100 : null;
|
||||
const lengthPct = lengthMax ? (lengthUsed / lengthMax) * 100 : null;
|
||||
@@ -95,7 +102,7 @@ export const TrainStatsBar = ({
|
||||
withBorder
|
||||
style={{ borderColor: "var(--mantine-color-gray-2)", background: "white" }}
|
||||
>
|
||||
<SimpleGrid cols={{ base: 1, xs: 3 }} spacing="lg">
|
||||
<SimpleGrid cols={{ base: 1, xs: showWagons ? 3 : 2 }} spacing="lg">
|
||||
<StatTile
|
||||
icon={<Weight size={15} />}
|
||||
label="Gross weight"
|
||||
@@ -108,7 +115,7 @@ export const TrainStatsBar = ({
|
||||
px={{ base: 0, xs: "lg" }}
|
||||
style={{
|
||||
borderLeft: "1px solid var(--mantine-color-gray-2)",
|
||||
borderRight: "1px solid var(--mantine-color-gray-2)",
|
||||
borderRight: showWagons ? "1px solid var(--mantine-color-gray-2)" : undefined,
|
||||
}}
|
||||
>
|
||||
<StatTile
|
||||
@@ -120,14 +127,16 @@ export const TrainStatsBar = ({
|
||||
unit="m"
|
||||
/>
|
||||
</Box>
|
||||
<StatTile
|
||||
icon={<Train size={15} />}
|
||||
label="Wagons"
|
||||
pct={wagonPct}
|
||||
current={String(wagonCount)}
|
||||
max={String(wagonMax)}
|
||||
unit=""
|
||||
/>
|
||||
{showWagons ? (
|
||||
<StatTile
|
||||
icon={<Train size={15} />}
|
||||
label="Wagons"
|
||||
pct={wagonPct}
|
||||
current={String(wagonCount)}
|
||||
max={String(wagonMax)}
|
||||
unit=""
|
||||
/>
|
||||
) : null}
|
||||
</SimpleGrid>
|
||||
</Paper>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user