mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
24 lines
494 B
TypeScript
24 lines
494 B
TypeScript
import useSWR from 'swr'
|
|
|
|
const fetcher = (path: string) => fetch(path).then((r) => r.json())
|
|
|
|
function useDaysBooked() {
|
|
const { data: daysBooked, error: daysBookedError } = useSWR(
|
|
'/api/daysbooked',
|
|
fetcher,
|
|
{
|
|
revalidateOnFocus: true,
|
|
revalidateOnReconnect: true,
|
|
focusThrottleInterval: 24 * 60 * 60 * 1000,
|
|
}
|
|
)
|
|
|
|
return {
|
|
daysBooked,
|
|
daysBookedError,
|
|
daysBookedLoading: !daysBooked && !daysBookedError,
|
|
}
|
|
}
|
|
|
|
export default useDaysBooked
|