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:
@@ -1,6 +1,5 @@
|
|||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import type { PeriodStats } from '../services/DataService';
|
import type { PeriodStats } from '../services/DataService';
|
||||||
import { countryCodeToFlag } from '../services/adapters/CesiumAdapter';
|
|
||||||
|
|
||||||
interface StatsPanelProps {
|
interface StatsPanelProps {
|
||||||
stats: PeriodStats | null;
|
stats: PeriodStats | null;
|
||||||
@@ -121,8 +120,13 @@ export function StatsPanel({ stats, loading, periodDays, source }: StatsPanelPro
|
|||||||
>
|
>
|
||||||
<span className="text-base">{MEDALS[i]}</span>
|
<span className="text-base">{MEDALS[i]}</span>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<p className="text-white text-sm font-medium truncate">
|
<p className="text-white text-sm font-medium truncate flex items-center gap-1.5">
|
||||||
{countryCodeToFlag(city.countryCode)}{city.countryCode ? ' ' : ''}{city.name}
|
{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>
|
||||||
<p className="text-[#6b7280] text-xs">{city.count} tx</p>
|
<p className="text-[#6b7280] text-xs">{city.count} tx</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -50,12 +50,9 @@ function latLngToCountryCode(lat: number, lng: number): string {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convertit un code ISO 3166-1 alpha-2 en emoji drapeau */
|
/** Nettoie le nom de ville Cesium+ : retire le code postal ("Paris, 75001" → "Paris") */
|
||||||
export function countryCodeToFlag(code: string): string {
|
export function cleanCityName(city: string): string {
|
||||||
if (!code || code.length !== 2) return '';
|
return city.split(',')[0].trim();
|
||||||
return String.fromCodePoint(
|
|
||||||
...code.toUpperCase().split('').map((c) => 0x1F1E0 - 65 + c.charCodeAt(0))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// geoPoint accepte n'importe quel type — Cesium+ utilise plusieurs formats ES geo_point
|
// geoPoint accepte n'importe quel type — Cesium+ utilise plusieurs formats ES geo_point
|
||||||
@@ -132,7 +129,7 @@ export async function resolveGeoByKeys(
|
|||||||
if (!geo) continue;
|
if (!geo) continue;
|
||||||
result.set(hit._id, {
|
result.set(hit._id, {
|
||||||
name: src.title ?? '',
|
name: src.title ?? '',
|
||||||
city: src.city ?? 'Inconnue',
|
city: cleanCityName(src.city ?? 'Inconnue'),
|
||||||
countryCode: latLngToCountryCode(geo.lat, geo.lng),
|
countryCode: latLngToCountryCode(geo.lat, geo.lng),
|
||||||
lat: geo.lat,
|
lat: geo.lat,
|
||||||
lng: geo.lng,
|
lng: geo.lng,
|
||||||
|
|||||||
Reference in New Issue
Block a user