import { normalizeWarning } from "@/lib/weather-utils"; import type { RawWarning, WeatherWarning } from "@/types/imgw"; const IMGW_WARNINGS_METEO_URL = "https://danepubliczne.imgw.pl/api/data/warningsmeteo"; export async function fetchMeteoWarnings(signal?: AbortSignal): Promise { const response = await fetch(IMGW_WARNINGS_METEO_URL, { headers: { accept: "application/json" }, next: { revalidate: 300 }, signal, }); if (!response.ok) throw new Error("Unable to load IMGW meteorological warnings."); const rows = await response.json() as RawWarning[]; return Array.isArray(rows) ? rows.map((warning, index) => normalizeWarning(warning, "meteo", index)) : []; }