Merged in feat/sw-2857-refactor-booking-flow-url-updates (pull request #2302)
feat(SW-2857): Refactor booking flow url updates * Add support for removing parameters when using initial values in serializeSearchParams * Don't manually write search params in rate store * Booking is already from live search params so no need * Fix input type in serializeBookingSearchParams Approved-by: Linus Flood
This commit is contained in:
@@ -22,39 +22,41 @@ export default function RatesProvider({
|
||||
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,
|
||||
}),
|
||||
[
|
||||
const modifyRateIndex = searchParams.has("modifyRateIndex")
|
||||
? Number(searchParams.get("modifyRateIndex"))
|
||||
: undefined
|
||||
|
||||
const store = useMemo(() => {
|
||||
return createRatesStore({
|
||||
booking,
|
||||
hotelType,
|
||||
intl,
|
||||
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,
|
||||
vat,
|
||||
]
|
||||
)
|
||||
initialActiveRoom: modifyRateIndex,
|
||||
})
|
||||
}, [
|
||||
booking,
|
||||
hotelType,
|
||||
intl,
|
||||
pathname,
|
||||
roomCategories,
|
||||
roomsAvailability,
|
||||
modifyRateIndex,
|
||||
vat,
|
||||
])
|
||||
|
||||
return <RatesContext.Provider value={store}>{children}</RatesContext.Provider>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user