mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 10:27:49 +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:
@@ -18,6 +18,7 @@ import {
|
||||
type TrafficEnrichmentData,
|
||||
} from '../api/adminTraffic';
|
||||
import { usePlatform } from '../platform/hooks/usePlatform';
|
||||
import { getFlagEmoji as _sharedGetFlagEmoji } from '../utils/subscriptionHelpers';
|
||||
|
||||
// ============ TanStack Table module augmentation ============
|
||||
|
||||
@@ -40,14 +41,9 @@ const formatBytes = (bytes: number): string => {
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
const getFlagEmoji = (countryCode: string): string => {
|
||||
if (!countryCode || countryCode.length !== 2) return '';
|
||||
const codePoints = countryCode
|
||||
.toUpperCase()
|
||||
.split('')
|
||||
.map((char) => 127397 + char.charCodeAt(0));
|
||||
return String.fromCodePoint(...codePoints);
|
||||
};
|
||||
// Локальная обёртка над общим helper'ом, чтобы внутренние сигнатуры (string)
|
||||
// оставались как были и call-sites не меняли.
|
||||
const getFlagEmoji = (countryCode: string): string => _sharedGetFlagEmoji(countryCode);
|
||||
|
||||
const formatCurrency = (kopeks: number): string => {
|
||||
const rubles = kopeks / 100;
|
||||
|
||||
Reference in New Issue
Block a user