"use client"; import type { ComponentType } from "react"; import { AlertTriangle, Droplet, Waves, type LucideProps } from "lucide-react"; import type { Hydrology, HydrologyNearest } from "@/types/site-finder"; interface Props { hydrology: Hydrology; } // Decorative water glyph per subtype — the text label already names the body // (река / ручей / озеро / канал), so the icon is aria-hidden. Lucide has no // distinct lake/canal glyph; flowing bodies use Waves, the rest use Droplet. const SUBTYPE_ICON: Record> = { river: Waves, stream: Droplet, lake_or_pond: Waves, canal: Waves, }; function subtypeLabel(subtype: HydrologyNearest["subtype"]): string { switch (subtype) { case "river": return "река"; case "stream": return "ручей"; case "lake_or_pond": return "озеро/пруд"; case "canal": return "канал"; default: return "водоём"; } } export function HydrologyBlock({ hydrology }: Props) { const top5 = hydrology.nearest.slice(0, 5); return (
Гидрология
{/* Flood risk banner */} {hydrology.flood_risk_flag && (
Возможная пойма — река/канал в <200м
)} {/* Nearest water bodies */} {top5.length === 0 ? (
Поблизости водных объектов нет
) : (
{top5.map((item, i) => { const Icon = SUBTYPE_ICON[item.subtype ?? ""] ?? Droplet; const label = subtypeLabel(item.subtype); const name = item.name ?? "б/н"; return (
{name} {label} — {Math.round(item.distance_m)} м
); })}
)} {/* Note */} {hydrology.note && (
{hydrology.note}
)}
); }