This commit is contained in:
Marshal
2026-07-10 11:08:14 +00:00
parent 7f841ea583
commit 45629e436e
2 changed files with 195 additions and 95 deletions

View File

@@ -43,8 +43,18 @@ export interface SaveRoutePayload {
* Human-readable route label: yard names, not yard codes. Staff read
* "Addis Ababa → Dire Dawa", not "ADDIS_ABABA → DIRE_DAWA". Falls back to the
* code only when a yard has no label.
*
* When milestones are present they ARE the full ordered corridor (origin first,
* destination last), so the label shows every stop:
* "Addis Ababa → Adama → Dire Dawa".
*/
export function formatRouteLabel(route: RouteRecord): string {
const stops = [...(route.milestones ?? [])]
.sort((a, b) => a.sequenceNo - b.sequenceNo)
.map((m) => m.yard?.label ?? m.yard?.code)
.filter((name): name is string => Boolean(name));
if (stops.length >= 2) return stops.join(' → ');
const origin =
route.originYard?.label ?? route.originYard?.code ?? 'Origin';
const dest =