diff --git a/src/features/flights-map/components/FlightsMapStartPage.tsx b/src/features/flights-map/components/FlightsMapStartPage.tsx index 166f711a..43902a2c 100644 --- a/src/features/flights-map/components/FlightsMapStartPage.tsx +++ b/src/features/flights-map/components/FlightsMapStartPage.tsx @@ -238,9 +238,10 @@ export const FlightsMapStartPage: FC = ({ if (!filterState.departure || !filterState.arrival) return []; if (filteredRoutes.length === 0) return []; - const first = filteredRoutes[0]!.route; - const depCode = first[0]!; - const arrCode = first[first.length - 1]!; + const firstRoute = filteredRoutes[0]?.route; + const depCode = firstRoute?.[0]; + const arrCode = firstRoute?.[firstRoute.length - 1]; + if (!firstRoute || !depCode || !arrCode) return []; const depCityCode = getCityCodeByAirportCode(dictionaries, depCode) ?? depCode; const arrCityCode = getCityCodeByAirportCode(dictionaries, arrCode) ?? arrCode; diff --git a/src/features/flights-map/routesToPolylines.ts b/src/features/flights-map/routesToPolylines.ts index 430b837a..e15214ff 100644 --- a/src/features/flights-map/routesToPolylines.ts +++ b/src/features/flights-map/routesToPolylines.ts @@ -38,12 +38,13 @@ export function routesToPolylines( const hasArrival = Boolean(filterState.arrival); const isSpiderMode = hasDeparture && !hasArrival; - if (isSpiderMode) { - const fromCode = toCity(filterState.departure!); + if (isSpiderMode && filterState.departure) { + const fromCode = toCity(filterState.departure); const destCodes = new Set(); for (const r of routes) { - if (r.route.length > 1) { - const dest = toCity(r.route[r.route.length - 1]!); + const last = r.route[r.route.length - 1]; + if (r.route.length > 1 && last) { + const dest = toCity(last); if (dest !== fromCode) destCodes.add(dest); } } @@ -74,7 +75,10 @@ export function intermediateCityIds( const ids = new Set(); for (const r of routes) { if (r.route.length <= 2) continue; - for (let i = 1; i < r.route.length - 1; i++) ids.add(toCity(r.route[i]!)); + for (let i = 1; i < r.route.length - 1; i++) { + const code = r.route[i]; + if (code) ids.add(toCity(code)); + } } return [...ids]; } diff --git a/src/features/online-board/components/OnlineBoardDetailsPage.tsx b/src/features/online-board/components/OnlineBoardDetailsPage.tsx index a932e7d2..00467a7f 100644 --- a/src/features/online-board/components/OnlineBoardDetailsPage.tsx +++ b/src/features/online-board/components/OnlineBoardDetailsPage.tsx @@ -339,9 +339,11 @@ function FlightLegs({ - {i < legs.length - 1 && ( - - )} + {(() => { + const next = legs[i + 1]; + if (!next) return null; + return ; + })()} ))} @@ -368,7 +370,7 @@ function getLegs(flight: { routeType: string; leg?: IFlightLeg; legs?: IFlightLe export const OnlineBoardDetailsPage: FC = ({ flightId, locale, - canonicalOrigin, + canonicalOrigin: _canonicalOrigin, }) => { const { t } = useTranslation(); diff --git a/src/ui/errors/ErrorBoundary.tsx b/src/ui/errors/ErrorBoundary.tsx index f708177a..0a1cbe8c 100644 --- a/src/ui/errors/ErrorBoundary.tsx +++ b/src/ui/errors/ErrorBoundary.tsx @@ -19,9 +19,12 @@ interface ErrorBoundaryState { * and fall back to English for any language we don't have coverage * for. Mirrors what Angular's global ErrorHandler renders. */ +const FALLBACK_RU = { title: "Что-то пошло не так", retry: "Повторить" } as const; +const FALLBACK_EN = { title: "Something went wrong", retry: "Retry" } as const; + const FALLBACK_STRINGS: Record = { - ru: { title: "Что-то пошло не так", retry: "Повторить" }, - en: { title: "Something went wrong", retry: "Retry" }, + ru: FALLBACK_RU, + en: FALLBACK_EN, es: { title: "Algo salió mal", retry: "Reintentar" }, fr: { title: "Une erreur s'est produite", retry: "Réessayer" }, it: { title: "Qualcosa è andato storto", retry: "Riprova" }, @@ -32,10 +35,10 @@ const FALLBACK_STRINGS: Record = { }; function pickStrings(): { title: string; retry: string } { - if (typeof window === "undefined") return FALLBACK_STRINGS.ru!; + if (typeof window === "undefined") return FALLBACK_RU; const locale = resolveLocaleFromPath(window.location.pathname); const lang = locale ? localeToLanguage(locale) : "ru"; - return FALLBACK_STRINGS[lang] ?? FALLBACK_STRINGS.en!; + return FALLBACK_STRINGS[lang] ?? FALLBACK_EN; } /** diff --git a/src/ui/errors/ErrorPage.tsx b/src/ui/errors/ErrorPage.tsx index 9cb19976..491fa106 100644 --- a/src/ui/errors/ErrorPage.tsx +++ b/src/ui/errors/ErrorPage.tsx @@ -58,7 +58,14 @@ const ERROR_CONFIG: Record = { }, }; -const FALLBACK_CONFIG: ErrorConfig = ERROR_CONFIG["500"]!; +const FALLBACK_CONFIG: ErrorConfig = { + titleKey: "PAGE500.HEADER", + descriptionKey: "PAGE500.DESCRIPTION", + image: "/assets/img/lady500.png", + buyTicketKey: "PAGE500.BUY-TICKET", + homeKey: "PAGE500.TO-HOME", + supportKey: "PAGE500.SUPPORT", +}; export interface ErrorPageProps { /** HTTP status code ("404", "500", "503"). Unknown codes fall back to 500. */