Merged in fix/sw-3551-rsc-bookingflowconfig (pull request #2988)
fix(SW-3551): Fix issue with BookingConfigProvider in RSC * wip move config to pages * Move config providing to pages
This commit is contained in:
@@ -54,7 +54,7 @@ export default function BookingWidgetClient({
|
||||
const [originalOverflowY, setOriginalOverflowY] = useState<string | null>(
|
||||
null
|
||||
)
|
||||
const { bookingCodeEnabled } = useBookingFlowConfig()
|
||||
const bookingFlowConfig = useBookingFlowConfig()
|
||||
const storedBookingWidgetState = useBookingWidgetState()
|
||||
|
||||
const shouldFetchAutoComplete = !!data.hotelId || !!data.city
|
||||
@@ -128,7 +128,7 @@ export default function BookingWidgetClient({
|
||||
toDate: toDate.format("YYYY-MM-DD"),
|
||||
},
|
||||
bookingCode: {
|
||||
value: bookingCodeEnabled ? selectedBookingCode : "",
|
||||
value: bookingFlowConfig.bookingCodeEnabled ? selectedBookingCode : "",
|
||||
remember: false,
|
||||
},
|
||||
redemption: data.searchType === SEARCH_TYPE_REDEMPTION,
|
||||
@@ -228,7 +228,7 @@ export default function BookingWidgetClient({
|
||||
}, [data, methods, storedBookingWidgetState])
|
||||
|
||||
if (shouldShowSkeleton) {
|
||||
return <BookingWidgetSkeleton type={type} />
|
||||
return <BookingWidgetSkeleton type={type} config={bookingFlowConfig} />
|
||||
}
|
||||
|
||||
const classNames = bookingWidgetContainerVariants({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { BookingFlowConfig } from "../../../bookingFlowConfig/bookingFlowConfig"
|
||||
import {
|
||||
getPageSettingsBookingCode,
|
||||
isBookingWidgetHidden,
|
||||
@@ -9,6 +10,7 @@ import type { BookingWidgetProps } from ".."
|
||||
export async function FloatingBookingWidget({
|
||||
booking,
|
||||
lang,
|
||||
config,
|
||||
}: Omit<BookingWidgetProps, "type">) {
|
||||
const isHidden = await isBookingWidgetHidden(lang)
|
||||
|
||||
@@ -22,9 +24,11 @@ export async function FloatingBookingWidget({
|
||||
}
|
||||
|
||||
return (
|
||||
<FloatingBookingWidgetClient
|
||||
data={booking}
|
||||
pageSettingsBookingCodePromise={pageSettingsBookingCodePromise}
|
||||
/>
|
||||
<BookingFlowConfig config={config}>
|
||||
<FloatingBookingWidgetClient
|
||||
data={booking}
|
||||
pageSettingsBookingCodePromise={pageSettingsBookingCodePromise}
|
||||
/>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,30 +1,34 @@
|
||||
"use client"
|
||||
|
||||
import { BookingFlowConfigContextProvider } from "../../bookingFlowConfig/bookingFlowConfigContext"
|
||||
import { BookingWidgetFormSkeleton } from "./BookingWidgetForm"
|
||||
import { MobileToggleButtonSkeleton } from "./MobileToggleButton"
|
||||
import { bookingWidgetContainerVariants } from "./variant"
|
||||
|
||||
import styles from "./bookingWidget.module.css"
|
||||
|
||||
import type { BookingFlowConfig } from "../../bookingFlowConfig/bookingFlowConfig"
|
||||
import type { BookingWidgetClientProps } from "./Client"
|
||||
|
||||
export function BookingWidgetSkeleton({
|
||||
type = "full",
|
||||
config,
|
||||
}: {
|
||||
type?: BookingWidgetClientProps["type"]
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const classNames = bookingWidgetContainerVariants({
|
||||
type,
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<BookingFlowConfigContextProvider config={config}>
|
||||
<section className={classNames} style={{ top: 0 }}>
|
||||
<MobileToggleButtonSkeleton />
|
||||
<div className={styles.formContainer}>
|
||||
<BookingWidgetFormSkeleton type={type} />
|
||||
</div>
|
||||
</section>
|
||||
</>
|
||||
</BookingFlowConfigContextProvider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Suspense } from "react"
|
||||
|
||||
import { BookingFlowConfig } from "../../bookingFlowConfig/bookingFlowConfig"
|
||||
import {
|
||||
getPageSettingsBookingCode,
|
||||
isBookingWidgetHidden,
|
||||
@@ -39,13 +40,16 @@ export type BookingWidgetProps = {
|
||||
type?: BookingWidgetType
|
||||
booking: BookingWidgetSearchData
|
||||
lang: Lang
|
||||
config: BookingFlowConfig
|
||||
}
|
||||
|
||||
export async function BookingWidget(props: BookingWidgetProps) {
|
||||
export async function BookingWidget({ config, ...props }: BookingWidgetProps) {
|
||||
return (
|
||||
<Suspense fallback={<BookingWidgetSkeleton />}>
|
||||
<InternalBookingWidget {...props} />
|
||||
</Suspense>
|
||||
<BookingFlowConfig config={config}>
|
||||
<Suspense fallback={<BookingWidgetSkeleton config={config} />}>
|
||||
<InternalBookingWidget {...props} />
|
||||
</Suspense>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -53,7 +57,7 @@ async function InternalBookingWidget({
|
||||
lang,
|
||||
type,
|
||||
booking,
|
||||
}: BookingWidgetProps) {
|
||||
}: Omit<BookingWidgetProps, "config">) {
|
||||
const isHidden = await isBookingWidgetHidden(lang)
|
||||
|
||||
if (isHidden) {
|
||||
|
||||
Reference in New Issue
Block a user