chore(SW-3665): Upgrade to Next 16 * Upgrade partner-sas * Upgrade scandic-web to next 16 * Update peerDep versions * Fix revalidateTag * Remove comment * Merge branch 'master' into chore/upgrade-to-next16 * Update netlify adapter * Build with webpack instead of turbopack * Revert from proxy to middleware * Merge branch 'master' into chore/upgrade-to-next16 * Revert proxy type * Fix react types versions * 16.0.9 * Bump to 16.0.10 Approved-by: Linus Flood
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
"use client"
|
|
import { useSearchParams } from "next/navigation"
|
|
import { useRef } from "react"
|
|
|
|
import { createDestinationDataStore } from "@/stores/destination-data"
|
|
|
|
import { DestinationDataContext } from "@/contexts/DestinationData"
|
|
|
|
import DestinationDataProviderContent from "./Content"
|
|
|
|
import type { DestinationDataStore } from "@/types/contexts/destination-data"
|
|
import type { DestinationDataProviderProps } from "@/types/providers/destination-data"
|
|
|
|
export default function DestinationDataProvider({
|
|
allCities = [],
|
|
allHotels,
|
|
hotelFilters,
|
|
seoFilters,
|
|
sortItems,
|
|
pathname,
|
|
children,
|
|
}: DestinationDataProviderProps) {
|
|
const storeRef = useRef<DestinationDataStore>(undefined)
|
|
const searchParams = useSearchParams()
|
|
|
|
// eslint-disable-next-line react-hooks/refs
|
|
if (!storeRef.current) {
|
|
storeRef.current = createDestinationDataStore({
|
|
allCities,
|
|
allHotels,
|
|
hotelFilters,
|
|
seoFilters,
|
|
pathname,
|
|
sortItems,
|
|
searchParams,
|
|
})
|
|
}
|
|
|
|
return (
|
|
// eslint-disable-next-line react-hooks/refs
|
|
<DestinationDataContext.Provider value={storeRef.current}>
|
|
<DestinationDataProviderContent>
|
|
{children}
|
|
</DestinationDataProviderContent>
|
|
</DestinationDataContext.Provider>
|
|
)
|
|
}
|