Merged in feat/SW-3477-hide-voucher-booking-code-sas- (pull request #2836)

feat(SW-3477) Updated booking widget for SAS white label

Approved-by: Anton Gunnarsson
This commit is contained in:
Hrishikesh Vaipurkar
2025-09-23 08:44:55 +00:00
parent 046d342b6f
commit 16e6c1596c
21 changed files with 173 additions and 79 deletions

View File

@@ -5,9 +5,11 @@ import { cache } from "react"
import { BookingFlowConfigContextProvider } from "./bookingFlowConfigContext"
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
import type { ScandicPartnersEnum } from "@scandic-hotels/common/constants/scandicPartners"
export type BookingFlowConfig = {
bookingCodeEnabled: boolean
partner?: ScandicPartnersEnum
routes: {
myStay: LangRoute
bookingTermsAndConditions: LangRoute

View File

@@ -2,6 +2,8 @@
import { createContext, useContext } from "react"
import type { ScandicPartnersEnum } from "@scandic-hotels/common/constants/scandicPartners"
import type { BookingFlowConfig } from "./bookingFlowConfig"
type BookingFlowConfigContextData = BookingFlowConfig
@@ -10,6 +12,18 @@ const BookingFlowConfigContext = createContext<
BookingFlowConfigContextData | undefined
>(undefined)
export const useIsPartner = (partner: ScandicPartnersEnum) => {
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.partner === partner
}
export const useBookingFlowConfig = (): BookingFlowConfigContextData => {
const context = useContext(BookingFlowConfigContext)