feat: add global weather support
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m54s

This commit is contained in:
zv
2026-06-14 15:53:34 +02:00
parent d572c9cc53
commit 2182297adc
45 changed files with 739 additions and 212 deletions

View File

@@ -3,11 +3,12 @@
import { useQuery } from "@tanstack/react-query";
import { fetchForecast } from "@/lib/forecast-api";
import { QUERY_GC_TIME } from "@/lib/constants";
import type { WeatherRegion } from "@/types/weather-region";
export function useForecast(latitude?: number, longitude?: number) {
export function useForecast(latitude?: number, longitude?: number, region: WeatherRegion = "PL") {
return useQuery({
queryKey: ["forecast", latitude, longitude],
queryFn: ({ signal }) => fetchForecast(latitude as number, longitude as number, signal),
queryKey: ["forecast", region, latitude, longitude],
queryFn: ({ signal }) => fetchForecast(latitude as number, longitude as number, region, signal),
enabled: Number.isFinite(latitude) && Number.isFinite(longitude),
staleTime: 15 * 60 * 1000,
gcTime: QUERY_GC_TIME,