From 8ccf560bf5e9b5bdffd67e6d3b215786c3a96b35 Mon Sep 17 00:00:00 2001 From: gnezim Date: Sun, 19 Apr 2026 22:37:12 +0300 Subject: [PATCH] Resolve airport codes to parent city in popular requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/shared/hooks/useDictionaries.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/shared/hooks/useDictionaries.ts b/src/shared/hooks/useDictionaries.ts index 2565a9b7..6901f4f6 100644 --- a/src/shared/hooks/useDictionaries.ts +++ b/src/shared/hooks/useDictionaries.ts @@ -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; }