mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
fix(admin): show flag for every country code, not just hardcoded 25-36
User reported the EE (Estonia) flag rendered as plain text 'EE' on the
admin servers page. Root cause: getCountryFlag() in AdminServers.tsx
and AdminServerEdit.tsx hardcoded a 25-entry codeMap that didn't
include EE; falling through to 'return code' produced raw text.
Two other admin pages (AdminRemnawaveSquadDetail, AdminUserDetail)
had bigger 35-entry maps that did include EE — so EE worked there
but MX/AR/EG/ZA and friends still wouldn't. AdminRemnawave repeated
the same 35-entry map. AdminTrafficUsage already had the correct
algorithmic ISO→regional-indicator code but as a local duplicate of
utils/subscriptionHelpers.
Unify all six on the single algorithmic helper:
- getFlagEmoji() in utils/subscriptionHelpers.ts now:
* accepts string | null | undefined (callers don't need to guard)
* trims whitespace
* validates [A-Za-z]{2} before composing regional indicators
- Each admin page now either imports getFlagEmoji directly or wraps
it with the page's preferred fallback character (e.g. '🌍' for
empty codes where the UI expects a placeholder).
This commit is contained in:
@@ -24,51 +24,14 @@ import { createNumberInputHandler, toNumber } from '../utils/inputHelpers';
|
||||
import { usePermissionStore } from '../store/permissions';
|
||||
import { MessageMediaGrid } from '../components/tickets/MessageMediaGrid';
|
||||
import { linkifyText } from '../utils/linkify';
|
||||
import { getFlagEmoji } from '../utils/subscriptionHelpers';
|
||||
|
||||
// ============ Helpers ============
|
||||
|
||||
const getCountryFlag = (code: string | null | undefined): string => {
|
||||
if (!code) return '';
|
||||
const codeMap: Record<string, string> = {
|
||||
RU: '\u{1F1F7}\u{1F1FA}',
|
||||
US: '\u{1F1FA}\u{1F1F8}',
|
||||
DE: '\u{1F1E9}\u{1F1EA}',
|
||||
NL: '\u{1F1F3}\u{1F1F1}',
|
||||
GB: '\u{1F1EC}\u{1F1E7}',
|
||||
UK: '\u{1F1EC}\u{1F1E7}',
|
||||
FR: '\u{1F1EB}\u{1F1F7}',
|
||||
FI: '\u{1F1EB}\u{1F1EE}',
|
||||
SE: '\u{1F1F8}\u{1F1EA}',
|
||||
NO: '\u{1F1F3}\u{1F1F4}',
|
||||
PL: '\u{1F1F5}\u{1F1F1}',
|
||||
TR: '\u{1F1F9}\u{1F1F7}',
|
||||
JP: '\u{1F1EF}\u{1F1F5}',
|
||||
SG: '\u{1F1F8}\u{1F1EC}',
|
||||
HK: '\u{1F1ED}\u{1F1F0}',
|
||||
KR: '\u{1F1F0}\u{1F1F7}',
|
||||
AU: '\u{1F1E6}\u{1F1FA}',
|
||||
CA: '\u{1F1E8}\u{1F1E6}',
|
||||
CH: '\u{1F1E8}\u{1F1ED}',
|
||||
AT: '\u{1F1E6}\u{1F1F9}',
|
||||
IT: '\u{1F1EE}\u{1F1F9}',
|
||||
ES: '\u{1F1EA}\u{1F1F8}',
|
||||
BR: '\u{1F1E7}\u{1F1F7}',
|
||||
IN: '\u{1F1EE}\u{1F1F3}',
|
||||
AE: '\u{1F1E6}\u{1F1EA}',
|
||||
IL: '\u{1F1EE}\u{1F1F1}',
|
||||
KZ: '\u{1F1F0}\u{1F1FF}',
|
||||
UA: '\u{1F1FA}\u{1F1E6}',
|
||||
CZ: '\u{1F1E8}\u{1F1FF}',
|
||||
RO: '\u{1F1F7}\u{1F1F4}',
|
||||
LV: '\u{1F1F1}\u{1F1FB}',
|
||||
LT: '\u{1F1F1}\u{1F1F9}',
|
||||
EE: '\u{1F1EA}\u{1F1EA}',
|
||||
BG: '\u{1F1E7}\u{1F1EC}',
|
||||
HU: '\u{1F1ED}\u{1F1FA}',
|
||||
MD: '\u{1F1F2}\u{1F1E9}',
|
||||
};
|
||||
return codeMap[code.toUpperCase()] || code;
|
||||
};
|
||||
// Алгоритмический ISO 3166-1 alpha-2 → regional indicator (вместо хардкод-словаря,
|
||||
// который не покрывал все страны: например, EE раньше плыл сырым текстом в одних
|
||||
// местах, MX/AR/EG до сих пор отсутствуют в других). Единая точка истины в utils.
|
||||
const getCountryFlag = (code: string | null | undefined): string => getFlagEmoji(code);
|
||||
|
||||
// ============ Icons ============
|
||||
|
||||
|
||||
Reference in New Issue
Block a user