1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import { useQuery } from "@tanstack/react-query";
import { fetchArrivals, fetchEstimates } from "../api/arrivals";
export const useStopArrivals = (
stopId: string,
reduced: boolean = false,
enabled: boolean = true
) => {
return useQuery({
queryKey: ["arrivals", stopId, reduced],
queryFn: () => fetchArrivals(stopId, reduced),
enabled: !!stopId && enabled,
refetchInterval: 15000,
retry: false,
});
};
export const useStopEstimates = (
stopId: string,
routeId: string,
viaStopId?: string,
enabled: boolean = true
) => {
return useQuery({
queryKey: ["estimates", stopId, routeId, viaStopId],
queryFn: () => fetchEstimates(stopId, routeId, viaStopId),
enabled: !!stopId && !!routeId && enabled,
refetchInterval: 15000,
retry: false,
});
};
|