mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
Revert "move daysbooked fetch to context"
This reverts commit 87b38e6d30.
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user