Files
web/packages/booking-flow/lib/bookingFlowConfig/bookingFlowConfigContext.tsx
Anton Gunnarsson c21d0dbc74 Merged in fix/sw-3495-booking-flow-links-to-web (pull request #2837)
fix: (SW-3495): Update booking-flow links in partner-sas

* Update links to scandic web in booking-flow

* Fix routeToScandicWeb util function


Approved-by: Hrishikesh Vaipurkar
2025-09-22 13:30:38 +00:00

38 lines
903 B
TypeScript

"use client"
import { createContext, useContext } from "react"
import type { BookingFlowConfig } from "./bookingFlowConfig"
type BookingFlowConfigContextData = BookingFlowConfig
const BookingFlowConfigContext = createContext<
BookingFlowConfigContextData | undefined
>(undefined)
export const useBookingFlowConfig = (): BookingFlowConfigContextData => {
const context = useContext(BookingFlowConfigContext)
if (!context) {
throw new Error(
"useBookingFlowConfig must be used within a BookingFlowConfigContextProvider. Did you forget to use BookingFlowConfig in the consuming app?"
)
}
return context
}
export function BookingFlowConfigContextProvider({
children,
config,
}: {
children: React.ReactNode
config: BookingFlowConfig
}) {
return (
<BookingFlowConfigContext.Provider value={config}>
{children}
</BookingFlowConfigContext.Provider>
)
}