booking operations and trains scheduling also allocations

This commit is contained in:
marshal
2026-06-10 00:48:32 +03:00
parent 675975bc08
commit 5774d7db9d
180 changed files with 13423 additions and 3877 deletions

View File

@@ -0,0 +1,40 @@
import type { ReactNode } from "react";
import { Badge, Text } from "@mantine/core";
import type { ColumnFormat } from "@/pages/ruleEngine/config/resources";
import { formatCell as formatRuleEngineCell } from "@/components/ruleEngine/ruleEngineFormat";
export type FleetColumnFormat = ColumnFormat | "statusBadge";
const optionLabelMap = new Map<string, Map<string, string>>();
export const registerFleetOptionLabels = (
fieldKey: string,
options: { value: string; label: string }[],
) => {
optionLabelMap.set(fieldKey, new Map(options.map((o) => [o.value, o.label])));
};
export const formatFleetCell = (
value: unknown,
format?: FleetColumnFormat,
accessorKey?: string,
): ReactNode => {
if (format === "statusBadge") {
const status = value == null || value === "" ? "—" : String(value);
return (
<Badge variant="light" color="gray" size="sm" radius="md">
{status}
</Badge>
);
}
if (accessorKey && optionLabelMap.has(accessorKey)) {
const label = optionLabelMap.get(accessorKey)?.get(String(value ?? ""));
if (label) {
return <Text size="sm">{label}</Text>;
}
}
return formatRuleEngineCell(value, format as ColumnFormat | undefined);
};