fix: replace emoji flags with text badges, clean city names from postal codes

Emoji flags render as boxes on Linux. Replace with a small FR/BE/CH
badge. Also strip postal codes from Cesium+ city names (e.g.
"Saint-Jean-de-Laur, 46260" → "Saint-Jean-de-Laur").

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
syoul
2026-03-22 18:53:42 +01:00
parent 8d9a9a3c07
commit 55d2b50cd3
2 changed files with 11 additions and 10 deletions

View File

@@ -1,6 +1,5 @@
import { useRef } from 'react';
import type { PeriodStats } from '../services/DataService';
import { countryCodeToFlag } from '../services/adapters/CesiumAdapter';
interface StatsPanelProps {
stats: PeriodStats | null;
@@ -121,8 +120,13 @@ export function StatsPanel({ stats, loading, periodDays, source }: StatsPanelPro
>
<span className="text-base">{MEDALS[i]}</span>
<div className="flex-1 min-w-0">
<p className="text-white text-sm font-medium truncate">
{countryCodeToFlag(city.countryCode)}{city.countryCode ? ' ' : ''}{city.name}
<p className="text-white text-sm font-medium truncate flex items-center gap-1.5">
{city.countryCode && (
<span className="shrink-0 text-[10px] font-bold bg-[#1e1f2a] text-[#6b7280] rounded px-1 py-0.5 leading-none">
{city.countryCode}
</span>
)}
{city.name}
</p>
<p className="text-[#6b7280] text-xs">{city.count} tx</p>
</div>

View File

@@ -50,12 +50,9 @@ function latLngToCountryCode(lat: number, lng: number): string {
return '';
}
/** Convertit un code ISO 3166-1 alpha-2 en emoji drapeau */
export function countryCodeToFlag(code: string): string {
if (!code || code.length !== 2) return '';
return String.fromCodePoint(
...code.toUpperCase().split('').map((c) => 0x1F1E0 - 65 + c.charCodeAt(0))
);
/** Nettoie le nom de ville Cesium+ : retire le code postal ("Paris, 75001" → "Paris") */
export function cleanCityName(city: string): string {
return city.split(',')[0].trim();
}
// geoPoint accepte n'importe quel type — Cesium+ utilise plusieurs formats ES geo_point
@@ -132,7 +129,7 @@ export async function resolveGeoByKeys(
if (!geo) continue;
result.set(hit._id, {
name: src.title ?? '',
city: src.city ?? 'Inconnue',
city: cleanCityName(src.city ?? 'Inconnue'),
countryCode: latLngToCountryCode(geo.lat, geo.lng),
lat: geo.lat,
lng: geo.lng,