fix: use IMGW Hybrid for current weather

This commit is contained in:
zv
2026-06-02 16:18:10 +02:00
parent 22b8969379
commit fe73bc23ef
13 changed files with 267 additions and 36 deletions

View File

@@ -0,0 +1,18 @@
"use client";
import { useQuery } from "@tanstack/react-query";
import { fetchImgwCurrentWeather } from "@/lib/imgw-current-api";
import { QUERY_GC_TIME } from "@/lib/constants";
const CURRENT_WEATHER_STALE_TIME = 2 * 60 * 1000;
export function useCurrentWeather(latitude?: number, longitude?: number) {
return useQuery({
queryKey: ["imgw-current-weather", latitude, longitude],
queryFn: ({ signal }) => fetchImgwCurrentWeather(latitude as number, longitude as number, signal),
staleTime: CURRENT_WEATHER_STALE_TIME,
gcTime: QUERY_GC_TIME,
retry: 1,
enabled: Number.isFinite(latitude) && Number.isFinite(longitude),
});
}