mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 08:20:58 +00:00
booking operations and trains scheduling also allocations
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import type { FleetResourceConfig } from "@/pages/fleet/config/resources";
|
||||
|
||||
export interface FleetCardPresentation {
|
||||
titleKey: string;
|
||||
subtitleKey?: string;
|
||||
codeKey?: string;
|
||||
statusKey?: string;
|
||||
}
|
||||
|
||||
export const resolveFleetCardPresentation = (config: FleetResourceConfig): FleetCardPresentation => {
|
||||
const titleKey =
|
||||
config.cardTitleKey ??
|
||||
config.columns.find((col) => col.format !== "code" && col.accessorKey !== "status")
|
||||
?.accessorKey ??
|
||||
"id";
|
||||
|
||||
const codeKey =
|
||||
config.cardCodeKey ?? config.columns.find((col) => col.format === "code")?.accessorKey;
|
||||
|
||||
const statusKey = config.columns.find((col) => col.format === "statusBadge")?.accessorKey;
|
||||
|
||||
const subtitleKey =
|
||||
config.cardSubtitleKey ??
|
||||
config.columns.find(
|
||||
(col) =>
|
||||
col.accessorKey !== titleKey &&
|
||||
col.accessorKey !== codeKey &&
|
||||
col.accessorKey !== statusKey,
|
||||
)?.accessorKey;
|
||||
|
||||
return { titleKey, subtitleKey, codeKey, statusKey };
|
||||
};
|
||||
|
||||
export const cardInitials = (title: string) => {
|
||||
const parts = title.trim().split(/\s+/).filter(Boolean);
|
||||
if (!parts.length) return "?";
|
||||
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
||||
return `${parts[0][0] ?? ""}${parts[1][0] ?? ""}`.toUpperCase();
|
||||
};
|
||||
Reference in New Issue
Block a user