"use client"; import { Droplets, Sun, Thermometer, Wind } from "@/components/icons/platform-icons"; import { Cloud, CloudDrizzle, CloudFog, CloudLightning, CloudRain, CloudSnow, CloudSun, } from "@/components/icons/platform-icons"; import { PopoverShell } from "@/modules/system/components/status-bar/popover-shell"; import { formatTemperature } from "@/modules/system/components/status-bar/utils"; import type { WeatherSnapshot } from "@/lib/shared/contracts/weather"; type WeatherPopoverProps = { weather: WeatherSnapshot | undefined; onClose: () => void; }; export function WeatherPopover({ weather, onClose }: WeatherPopoverProps) { const mainTemperature = formatTemperature(weather?.current.temperatureC); const feelsLike = formatTemperature(weather?.current.feelsLikeC); const hasMainTemperature = typeof weather?.current.temperatureC === "number"; const hasFeelsLike = typeof weather?.current.feelsLikeC === "number"; const dailyForecast = weather?.dailyForecast ?? []; return (

{weather?.location.label ?? "Unknown location"}

{mainTemperature} {hasMainTemperature ? "C" : ""}

{weather?.current.condition ?? "Unknown"}

Hum {weather?.current.humidityPercent ?? "--"}% Wind {weather?.current.windSpeedKph ?? "--"} km/h Feels {feelsLike} {hasFeelsLike ? "C" : ""}

Next 5 Days

{dailyForecast.length > 0 ? ( dailyForecast.map((day) => (
{new Date(`${day.date}T00:00:00`).toLocaleDateString(undefined, { weekday: "short", })} {day.condition} {formatTemperature(day.tempMaxC)}/{formatTemperature(day.tempMinC)}
)) ) : ( No forecast available )}
); } function ForecastIcon({ weatherCode }: { weatherCode: number | null }) { if (weatherCode === null) { return ; } if (weatherCode === 0) { return ; } if (weatherCode === 1 || weatherCode === 2) { return ; } if (weatherCode === 3) { return ; } if (weatherCode === 45 || weatherCode === 48) { return ; } if (weatherCode >= 51 && weatherCode <= 57) { return ; } if ((weatherCode >= 61 && weatherCode <= 67) || (weatherCode >= 80 && weatherCode <= 82)) { return ; } if ((weatherCode >= 71 && weatherCode <= 77) || weatherCode === 85 || weatherCode === 86) { return ; } if (weatherCode === 95 || weatherCode === 96 || weatherCode === 99) { return ; } return ; }