Feat/SW-2271 hotel list filtering
* feat(SW-2271): Changes to hotel data types in preperation for filtering * feat(SW-2271): Added filter and sort functionality Approved-by: Matilda Landström
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"use client"
|
||||
import { useSearchParams } from "next/navigation"
|
||||
import { useRef } from "react"
|
||||
|
||||
import { createHotelListingDataStore } from "@/stores/hotel-listing-data"
|
||||
|
||||
import { HotelListingDataContext } from "@/contexts/HotelListingData"
|
||||
|
||||
import HotelListingDataProviderContent from "./Content"
|
||||
|
||||
import type { HotelListingDataStore } from "@/types/contexts/hotel-listing-data"
|
||||
import type { HotelListingDataProviderProps } from "@/types/providers/hotel-listing-data"
|
||||
|
||||
export default function HotelListingDataProvider({
|
||||
allHotels,
|
||||
allFilters,
|
||||
sortItems,
|
||||
children,
|
||||
}: HotelListingDataProviderProps) {
|
||||
const storeRef = useRef<HotelListingDataStore>(undefined)
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
if (!storeRef.current) {
|
||||
storeRef.current = createHotelListingDataStore({
|
||||
allHotels,
|
||||
allFilters,
|
||||
sortItems,
|
||||
searchParams,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<HotelListingDataContext.Provider value={storeRef.current}>
|
||||
<HotelListingDataProviderContent>
|
||||
{children}
|
||||
</HotelListingDataProviderContent>
|
||||
</HotelListingDataContext.Provider>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user