Resolve airport codes to parent city in popular requests
Angular's getCityOrAirport walks airport→city when the input code is an airport (SVO → Москва), only falling back to the airport name when no parent city is dictionarised. React was returning the raw airport name (Шереметьево) on the popular requests panel.
This commit is contained in:
@@ -26,6 +26,15 @@ export function useCityName(code: string): string {
|
||||
const city = dictionaries.cityByCode.get(upper);
|
||||
if (city) return city.name;
|
||||
const airport = dictionaries.airportByCode.get(upper);
|
||||
if (airport) return airport.name;
|
||||
if (airport) {
|
||||
// Angular's `getCityOrAirport` resolves airport codes up to their
|
||||
// parent city when possible (SVO → Москва) — only falls back to
|
||||
// the airport name when the city isn't dictionarised.
|
||||
const parent = airport.city_code
|
||||
? dictionaries.cityByCode.get(airport.city_code.toUpperCase())
|
||||
: null;
|
||||
if (parent) return parent.name;
|
||||
return airport.name;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user