/** * Country code (cc) to name for leagues sidebar. * Leagues API returns cc in lowercase; countries.json uses uppercase codes. */ import countriesJson from "@/countries.json" type CountryEntry = { name: string; code: string } const CODE_TO_NAME: Record = (countriesJson as CountryEntry[]).reduce( (acc, c) => { acc[c.code.toLowerCase()] = c.name return acc }, {} as Record ) /** Get country name from league cc (e.g. "al" -> "Albania"). Returns "International" for empty cc. */ export function getCountryName(cc: string): string { if (!cc || !cc.trim()) return "International" return CODE_TO_NAME[cc.toLowerCase()] ?? cc.toUpperCase() }