fix: select-rate didn't update results when switching back to a recent search SW-2890 * fix: select-rate didn't update results when switching back to a recent search Approved-by: Linus Flood
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
"use client"
|
|
|
|
import { usePathname, useSearchParams } from "next/navigation"
|
|
import { useMemo } from "react"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { createRatesStore } from "@/stores/select-rate"
|
|
|
|
import { RatesContext } from "@/contexts/Rates"
|
|
|
|
import type { RatesProviderProps } from "@/types/providers/rates"
|
|
|
|
export default function RatesProvider({
|
|
booking,
|
|
children,
|
|
hotelType,
|
|
roomCategories,
|
|
roomsAvailability,
|
|
vat,
|
|
}: RatesProviderProps) {
|
|
const pathname = usePathname()
|
|
const searchParams = useSearchParams()
|
|
const intl = useIntl()
|
|
|
|
const store = useMemo(
|
|
() =>
|
|
createRatesStore({
|
|
booking,
|
|
hotelType,
|
|
labels: {
|
|
accessibilityRoom: intl.formatMessage({
|
|
defaultMessage: "Accessible room",
|
|
}),
|
|
allergyRoom: intl.formatMessage({
|
|
defaultMessage: "Allergy-friendly room",
|
|
}),
|
|
petRoom: intl.formatMessage({
|
|
defaultMessage: "Pet-friendly room",
|
|
}),
|
|
},
|
|
pathname,
|
|
roomCategories,
|
|
roomsAvailability,
|
|
searchParams: new URLSearchParams(searchParams),
|
|
vat,
|
|
}),
|
|
[
|
|
booking,
|
|
hotelType,
|
|
intl,
|
|
pathname,
|
|
roomCategories,
|
|
roomsAvailability,
|
|
searchParams,
|
|
vat,
|
|
]
|
|
)
|
|
|
|
return <RatesContext.Provider value={store}>{children}</RatesContext.Provider>
|
|
}
|