Merged in chore/cleanup-booking-flow (pull request #2824)
chore: Cleanup booking-flow after migration * Remove unused types * Clean up exports, types, unused files etc in booking-flow Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
"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 modifyRateIndex = searchParams.has("activeRoomIndex")
|
||||
? Number(searchParams.get("activeRoomIndex"))
|
||||
: undefined
|
||||
|
||||
const store = useMemo(() => {
|
||||
return 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,
|
||||
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