feat: build production-ready wtr weather PWA
This commit is contained in:
15
hooks/use-hydro.ts
Normal file
15
hooks/use-hydro.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { fetchHydroStations } from "@/lib/imgw-api";
|
||||
import { QUERY_GC_TIME, QUERY_STALE_TIME } from "@/lib/constants";
|
||||
|
||||
export function useHydroStations() {
|
||||
return useQuery({
|
||||
queryKey: ["hydro-stations"],
|
||||
queryFn: ({ signal }) => fetchHydroStations(signal),
|
||||
staleTime: QUERY_STALE_TIME,
|
||||
gcTime: QUERY_GC_TIME,
|
||||
retry: 2,
|
||||
});
|
||||
}
|
||||
15
hooks/use-warnings.ts
Normal file
15
hooks/use-warnings.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { fetchWarnings } from "@/lib/imgw-api";
|
||||
import { QUERY_GC_TIME, QUERY_STALE_TIME } from "@/lib/constants";
|
||||
|
||||
export function useWarnings() {
|
||||
return useQuery({
|
||||
queryKey: ["warnings"],
|
||||
queryFn: ({ signal }) => fetchWarnings(signal),
|
||||
staleTime: QUERY_STALE_TIME,
|
||||
gcTime: QUERY_GC_TIME,
|
||||
retry: 2,
|
||||
});
|
||||
}
|
||||
26
hooks/use-weather-stations.ts
Normal file
26
hooks/use-weather-stations.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { fetchSynopStation, fetchSynopStations } from "@/lib/imgw-api";
|
||||
import { QUERY_GC_TIME, QUERY_STALE_TIME } from "@/lib/constants";
|
||||
|
||||
export function useWeatherStations() {
|
||||
return useQuery({
|
||||
queryKey: ["synop-stations"],
|
||||
queryFn: ({ signal }) => fetchSynopStations(signal),
|
||||
staleTime: QUERY_STALE_TIME,
|
||||
gcTime: QUERY_GC_TIME,
|
||||
retry: 2,
|
||||
});
|
||||
}
|
||||
|
||||
export function useWeatherStation(id: string) {
|
||||
return useQuery({
|
||||
queryKey: ["synop-station", id],
|
||||
queryFn: ({ signal }) => fetchSynopStation(id, signal),
|
||||
staleTime: QUERY_STALE_TIME,
|
||||
gcTime: QUERY_GC_TIME,
|
||||
retry: 2,
|
||||
enabled: Boolean(id),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user