feat(SW-3514): Add variant of join friends card with membership id input * Move membershipId input in enter details to join card Add booking flow feature flag to move membershipId into join card and hide login button. Currently only applies to first room. * Add sas join card to multiroom Approved-by: Hrishikesh Vaipurkar
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import "server-only"
|
|
|
|
import { cache } from "react"
|
|
|
|
import { BookingFlowConfigContextProvider } from "./bookingFlowConfigContext"
|
|
|
|
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
|
|
|
|
import type { BookingFlowVariant } from "./bookingFlowVariants"
|
|
|
|
export type BookingFlowConfig = {
|
|
bookingCodeEnabled: boolean
|
|
enterDetailsMembershipIdInputLocation: "form" | "join-card"
|
|
variant: BookingFlowVariant
|
|
routes: {
|
|
myStay: LangRoute
|
|
bookingTermsAndConditions: LangRoute
|
|
customerService: LangRoute
|
|
privacyPolicy: LangRoute
|
|
}
|
|
}
|
|
|
|
const getRef = cache(() => ({
|
|
current: undefined as BookingFlowConfig | undefined,
|
|
}))
|
|
|
|
function setBookingFlowConfig(newConfig: BookingFlowConfig) {
|
|
getRef().current = newConfig
|
|
}
|
|
|
|
export function getBookingFlowConfig(): BookingFlowConfig {
|
|
const contextConfig = getRef().current
|
|
|
|
if (!contextConfig) {
|
|
throw new Error("BookingFlowConfig not set")
|
|
}
|
|
|
|
return contextConfig
|
|
}
|
|
|
|
/*
|
|
* Sets up both a server side context and a client side context
|
|
* for the booking flow config.
|
|
*/
|
|
export async function BookingFlowConfig({
|
|
children,
|
|
config,
|
|
}: {
|
|
children: React.ReactNode
|
|
config: BookingFlowConfig
|
|
}) {
|
|
setBookingFlowConfig(config)
|
|
|
|
return (
|
|
<BookingFlowConfigContextProvider config={config}>
|
|
{children}
|
|
</BookingFlowConfigContextProvider>
|
|
)
|
|
}
|