Revert "move daysbooked fetch to context"

This reverts commit 87b38e6d30.
This commit is contained in:
Thomas Ruoff
2020-11-02 23:30:19 +01:00
parent cb9932240d
commit 8715e09563
2 changed files with 15 additions and 21 deletions

View File

@@ -2,9 +2,6 @@ import React, { useEffect, useReducer } from 'react'
import { useRouter } from 'next/router'
import { clearBookingData, loadBookingData } from '../../../helpers/storage'
import { ValidationError } from './validationError'
import useSWR from 'swr'
const fetcher = (path: string) => fetch(path).then((r) => r.json())
interface WizardFormData {
startDate: string
@@ -42,8 +39,6 @@ interface WizardStore {
onChangeEvent: (event: React.ChangeEvent<React.ElementRef<'input'>>) => void
onSubmit: () => void
forgetData: () => void
daysBooked: string[]
daysBookedErrorMessage: string
}
interface WizardAction {
@@ -169,15 +164,6 @@ async function createBooking(formData: WizardFormData) {
export default function WizardStore({ children }) {
const router = useRouter()
const [state, dispatch] = useReducer(reducer, initialState)
const { data: daysBooked, error: daysBookedError } = useSWR<string[], Error>(
'/api/daysbooked',
fetcher,
{
revalidateOnFocus: true,
revalidateOnReconnect: true,
focusThrottleInterval: 24 * 60 * 60 * 1000,
}
)
useEffect(() => {
const data = loadBookingData()
@@ -230,8 +216,6 @@ export default function WizardStore({ children }) {
onChange,
onSubmit,
forgetData,
daysBooked,
daysBookedErrorMessage: daysBookedError?.message,
}}
>
{children}