import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Marker, Popup } from 'react-map-gl/maplibre'; import { PIRACY_ZONES, PIRACY_LEVEL_COLOR, PIRACY_LEVEL_LABEL } from '../services/piracy'; import type { PiracyZone } from '../services/piracy'; function SkullIcon({ color, size }: { color: string; size: number }) { return ( ); } export function PiracyLayer() { const [selected, setSelected] = useState(null); const { t } = useTranslation(); return ( <> {PIRACY_ZONES.map(zone => { const color = PIRACY_LEVEL_COLOR[zone.level]; const size = zone.level === 'critical' ? 28 : zone.level === 'high' ? 24 : 20; return ( { e.originalEvent.stopPropagation(); setSelected(zone); }}>
{PIRACY_LEVEL_LABEL[zone.level]}
); })} {selected && ( setSelected(null)} closeOnClick={false} anchor="bottom" maxWidth="340px" className="gl-popup">
☠️ {selected.nameKo}
{PIRACY_LEVEL_LABEL[selected.level]} {selected.name} {selected.recentIncidents != null && ( {t('piracy.recentIncidents', { count: selected.recentIncidents })} )}
{selected.description}
{selected.detail}
{selected.lat.toFixed(2)}°N, {selected.lng.toFixed(2)}°E
)} ); }