fix: show placeholder badge for defunct nations with no flag-icons code
Soviet Union (su), Yugoslavia (yu), East Germany, Germany DR, FR Yugoslavia, and Czechoslovakia have no valid entry in flag-icons. Map them to null in TEAM_ISO so getIso() returns null, and render a muted initials badge in TeamFlag instead of a broken/empty sprite. Also drop the buggy 2-char substring fallback that generated random valid codes for unknown teams. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+9
-6
@@ -1,4 +1,4 @@
|
||||
export const TEAM_ISO: Record<string, string> = {
|
||||
export const TEAM_ISO: Record<string, string | null> = {
|
||||
// A
|
||||
'Afghanistan': 'af', 'Albania': 'al', 'Algeria': 'dz', 'Angola': 'ao',
|
||||
'Argentina': 'ar', 'Armenia': 'am', 'Australia': 'au', 'Austria': 'at',
|
||||
@@ -19,7 +19,8 @@ export const TEAM_ISO: Record<string, string> = {
|
||||
// F
|
||||
'Finland': 'fi', 'France': 'fr',
|
||||
// G
|
||||
'Gabon': 'ga', 'Germany': 'de', 'West Germany': 'de', 'East Germany': 'de',
|
||||
'Gabon': 'ga', 'Germany': 'de', 'West Germany': 'de',
|
||||
'East Germany': null, 'Germany DR': null,
|
||||
'Ghana': 'gh', 'Greece': 'gr', 'Guatemala': 'gt', 'Guinea': 'gn',
|
||||
// H
|
||||
'Haiti': 'ht', 'Honduras': 'hn', 'Hungary': 'hu',
|
||||
@@ -48,10 +49,11 @@ export const TEAM_ISO: Record<string, string> = {
|
||||
// Q
|
||||
'Qatar': 'qa',
|
||||
// R
|
||||
'Romania': 'ro', 'Russia': 'ru', 'Soviet Union': 'su',
|
||||
'Romania': 'ro', 'Russia': 'ru', 'Soviet Union': null,
|
||||
// S
|
||||
'Saudi Arabia': 'sa', 'Scotland': 'gb-sct', 'Senegal': 'sn',
|
||||
'Serbia': 'rs', 'Yugoslavia': 'yu', 'Slovakia': 'sk', 'Slovenia': 'si',
|
||||
'Serbia': 'rs', 'Yugoslavia': null, 'FR Yugoslavia': null, 'Czechoslovakia': null,
|
||||
'Slovakia': 'sk', 'Slovenia': 'si',
|
||||
'Somalia': 'so', 'South Africa': 'za', 'South Korea': 'kr',
|
||||
'Korea Republic': 'kr', 'Spain': 'es', 'Sweden': 'se', 'Switzerland': 'ch',
|
||||
// T
|
||||
@@ -68,8 +70,9 @@ export const TEAM_ISO: Record<string, string> = {
|
||||
'Zambia': 'zm', 'Zimbabwe': 'zw',
|
||||
}
|
||||
|
||||
export function getIso(teamName: string): string {
|
||||
return TEAM_ISO[teamName] ?? teamName.toLowerCase().replace(/\s+/g, '-').substring(0, 2)
|
||||
export function getIso(teamName: string): string | null {
|
||||
if (teamName in TEAM_ISO) return TEAM_ISO[teamName]
|
||||
return null
|
||||
}
|
||||
|
||||
export function slugify(name: string): string {
|
||||
|
||||
Reference in New Issue
Block a user