extract non-interactive calendar

This commit is contained in:
Thomas Ruoff
2020-11-03 21:05:47 +01:00
parent 8715e09563
commit 0a75eb0404
4 changed files with 60 additions and 25 deletions

23
helpers/useDaysBooked.ts Normal file
View File

@@ -0,0 +1,23 @@
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