Tidy up train service component, add loading state, convert tiploc to name... etc.

This commit is contained in:
2026-05-03 11:45:07 +01:00
parent 24960707e2
commit 5486795711
6 changed files with 120 additions and 31 deletions

View File

@@ -28,6 +28,20 @@ class LocationStore {
return loc.t === query || loc.c === query;
});
}
getName(code: string | number | null | undefined): ApiLocationFilter.LocationFilterObject | null {
try {
if (!code) return null;
const query = String(code).toUpperCase().trim();
const match = this.data.find((loc) => loc.t === query || loc.c === query);
return match ?? null;
} catch (e) {
console.error('Error finding location object: ', e);
return null;
}
}
}
export const LOCATIONS = new LocationStore();