mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
- Introduced DEACTIVATED status for trains, allowing staff to park trains indefinitely. - Implemented methods to deactivate and reactivate trains in the TrainBuilderService. - Added UI components for train deactivation and reactivation in TrainBuilderDetailPage. - Created a dropdown setting for admin-managed import train numbers, with corresponding migrations. - Updated yard code length to accommodate soft-delete suffix. - Enhanced train status handling to include DEACTIVATED state.
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import type { CSSProperties } from "react";
|
|
|
|
import type { BuiltTrainStatus } from "@/services/trainBuilder.service";
|
|
|
|
/** Badge color per built-train lifecycle status (Mantine palette keys). */
|
|
export const trainStatusColor = (status: BuiltTrainStatus | string): string => {
|
|
switch (status) {
|
|
case "AVAILABLE":
|
|
return "edr-green";
|
|
case "SCHEDULED":
|
|
return "blue";
|
|
case "IN_SERVICE":
|
|
return "teal";
|
|
case "UNDER_MAINTENANCE":
|
|
return "yellow";
|
|
case "OUT_OF_SERVICE":
|
|
return "red";
|
|
case "DEACTIVATED":
|
|
return "gray";
|
|
default:
|
|
return "gray";
|
|
}
|
|
};
|
|
|
|
export const trainStatusLabel = (status: BuiltTrainStatus | string): string =>
|
|
String(status)
|
|
.toLowerCase()
|
|
.replace(/_/g, " ")
|
|
.replace(/^\w/, (c) => c.toUpperCase());
|
|
|
|
/** Badge color per trade direction (Mantine palette keys). */
|
|
export const directionColor = (direction?: string | null): string =>
|
|
direction === "IMPORT" ? "blue" : direction === "EXPORT" ? "orange" : "gray";
|
|
|
|
/** Row background tint for a train whose active schedule runs in `direction`. */
|
|
export const directionRowStyle = (
|
|
direction?: string | null,
|
|
): CSSProperties | undefined =>
|
|
direction === "IMPORT"
|
|
? { backgroundColor: "var(--mantine-color-blue-0)" }
|
|
: direction === "EXPORT"
|
|
? { backgroundColor: "var(--mantine-color-orange-0)" }
|
|
: undefined;
|