"use client"; import type { SeasonalWeather, SeasonStats } from "@/types/site-finder"; interface Props { seasonal: SeasonalWeather | null | undefined; } const SEASON_CONFIG: Array<{ key: keyof SeasonalWeather["seasons"]; label: string; bg: string; color: string; }> = [ { key: "winter", label: "Зима", bg: "#dbeafe", color: "#1e40af" }, { key: "spring", label: "Весна", bg: "#dcfce7", color: "#15803d" }, { key: "summer", label: "Лето", bg: "#fef3c7", color: "#92400e" }, { key: "autumn", label: "Осень", bg: "#fed7aa", color: "#c2410c" }, ]; function SeasonCard({ label, bg, color, stats, }: { label: string; bg: string; color: string; stats: SeasonStats; }) { return (
{label}
{stats.avg_t_min_c}…{stats.avg_t_max_c}°C
(макс ↓{stats.min_t_c} / ↑{stats.max_t_c}°C)
{stats.total_precip_mm} мм осадков
); } export function SeasonalWeatherBlock({ seasonal }: Props) { if (!seasonal) { return (
Климат (нормали)
Климат-данные недоступны
); } return (
{/* Header */}
Климат (нормали)
{seasonal.period}
{/* Season cards */}
{SEASON_CONFIG.map(({ key, label, bg, color }) => { const stats = seasonal.seasons[key]; if (!stats) { return (
{label}
Нет данных
); } return ( ); })}
{/* Footer */}
{seasonal.source} · {seasonal.model}
); }