mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 21:50:57 +00:00
Merge freight/develop into feature/trains-management
This commit is contained in:
@@ -61,5 +61,45 @@ export const formatCell = (value: unknown, format?: ColumnFormat): ReactNode =>
|
||||
return Number.isNaN(d.getTime()) ? String(value) : d.toLocaleDateString();
|
||||
}
|
||||
|
||||
if (format === "entityLabel" && value && typeof value === "object") {
|
||||
const entity = value as { label?: string; code?: string; cargoTypeName?: string };
|
||||
const label =
|
||||
entity.label?.trim() ||
|
||||
entity.cargoTypeName?.trim() ||
|
||||
entity.code?.trim();
|
||||
return label ? (
|
||||
<span>{label}</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground">—</span>
|
||||
);
|
||||
}
|
||||
|
||||
if (format === "rateLabel") {
|
||||
if (!value || typeof value !== "object") {
|
||||
return value ? (
|
||||
<span className="font-mono text-xs text-muted-foreground">{String(value)}</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground">—</span>
|
||||
);
|
||||
}
|
||||
const rate = value as {
|
||||
rateType?: string;
|
||||
currency?: string;
|
||||
rateValue?: number;
|
||||
rateUnit?: string;
|
||||
};
|
||||
const parts = [
|
||||
rate.rateType?.replace(/_/g, " "),
|
||||
rate.currency,
|
||||
rate.rateValue != null ? String(rate.rateValue) : "",
|
||||
rate.rateUnit?.replace(/_/g, " "),
|
||||
].filter(Boolean);
|
||||
return parts.length > 0 ? (
|
||||
<span>{parts.join(" · ")}</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground">—</span>
|
||||
);
|
||||
}
|
||||
|
||||
return String(value);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user