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:
Anton Gunnarsson
2025-10-22 07:04:21 +00:00
parent 2a28681259
commit c435cdba68
44 changed files with 398 additions and 237 deletions

View File

@@ -1,5 +1,7 @@
import { BookingConfirmationPage as BookingConfirmationPagePrimitive } from "@scandic-hotels/booking-flow/pages/BookingConfirmationPage"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
@@ -17,6 +19,7 @@ export default async function BookingConfirmationPage(
intl={intl}
lang={lang}
searchParams={searchParams}
config={bookingFlowConfig}
/>
)
}

View File

@@ -2,6 +2,8 @@ import { PaymentCallbackPage as PaymentCallbackPagePrimitive } from "@scandic-ho
import { logger } from "@scandic-hotels/common/logger"
import { isValidSession } from "@scandic-hotels/trpc/utils/session"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { auth } from "@/auth"
import type { PaymentCallbackStatusEnum } from "@scandic-hotels/common/constants/paymentCallbackStatusEnum"
@@ -35,6 +37,7 @@ export default async function PaymentCallbackPage(
searchParams={searchParams}
// TODO refactor this route to get this from params instead of rewriting in next.config
status={searchParams.status as PaymentCallbackStatusEnum}
config={bookingFlowConfig}
/>
)
}

View File

@@ -1,5 +1,6 @@
import { AlternativeHotelsMapPage as AlternativeHotelsMapPagePrimitive } from "@scandic-hotels/booking-flow/pages/AlternativeHotelsMapPage"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getHotel } from "@/lib/trpc/memoizedRequests"
import { getIntl } from "@/i18n"
@@ -58,6 +59,7 @@ export default async function AlternativeHotelsMapPage(
<AlternativeHotelsMapPagePrimitive
lang={lang}
searchParams={searchParams}
config={bookingFlowConfig}
/>
</div>
)

View File

@@ -1,5 +1,6 @@
import { AlternativeHotelsPage as AlternativeHotelsPagePrimitive } from "@scandic-hotels/booking-flow/pages/AlternativeHotelsPage"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getHotel } from "@/lib/trpc/memoizedRequests"
import { getIntl } from "@/i18n"
@@ -55,6 +56,10 @@ export default async function AlternativeHotelsPage(
const searchParams = await props.searchParams
const lang = await getLang()
return (
<AlternativeHotelsPagePrimitive lang={lang} searchParams={searchParams} />
<AlternativeHotelsPagePrimitive
lang={lang}
searchParams={searchParams}
config={bookingFlowConfig}
/>
)
}

View File

@@ -1,5 +1,7 @@
import { EnterDetailsPage as EnterDetailsPagePrimitive } from "@scandic-hotels/booking-flow/pages/EnterDetailsPage"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
export default async function DetailsPage(
@@ -8,5 +10,11 @@ export default async function DetailsPage(
const { lang } = await props.params
const searchParams = await props.searchParams
return <EnterDetailsPagePrimitive lang={lang} searchParams={searchParams} />
return (
<EnterDetailsPagePrimitive
lang={lang}
searchParams={searchParams}
config={bookingFlowConfig}
/>
)
}

View File

@@ -1,6 +1,8 @@
import { SelectHotelMapPage as SelectHotelMapPagePrimitive } from "@scandic-hotels/booking-flow/pages/SelectHotelMapPage"
import { toCapitalCase } from "@scandic-hotels/common/utils/toCapitalCase"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getLang } from "@/i18n/serverContext"
import styles from "./page.module.css"
@@ -27,7 +29,11 @@ export default async function SelectHotelMapPage(
return (
<div className={styles.main}>
<SelectHotelMapPagePrimitive lang={lang} searchParams={searchParams} />
<SelectHotelMapPagePrimitive
lang={lang}
searchParams={searchParams}
config={bookingFlowConfig}
/>
</div>
)
}

View File

@@ -1,6 +1,8 @@
import { SelectHotelPage as SelectHotelPagePrimitive } from "@scandic-hotels/booking-flow/pages/SelectHotelPage"
import { toCapitalCase } from "@scandic-hotels/common/utils/toCapitalCase"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getLang } from "@/i18n/serverContext"
import type { Metadata } from "next"
@@ -23,5 +25,11 @@ export default async function SelectHotelPage(
const searchParams = await props.searchParams
const lang = await getLang()
return <SelectHotelPagePrimitive lang={lang} searchParams={searchParams} />
return (
<SelectHotelPagePrimitive
lang={lang}
searchParams={searchParams}
config={bookingFlowConfig}
/>
)
}

View File

@@ -1,5 +1,6 @@
import { SelectRatePage as SelectRatePagePrimitive } from "@scandic-hotels/booking-flow/pages/SelectRatePage"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getHotel } from "@/lib/trpc/memoizedRequests"
import { getLang } from "@/i18n/serverContext"
@@ -40,5 +41,11 @@ export default async function SelectRatePage(
const searchParams = await props.searchParams
const lang = await getLang()
return <SelectRatePagePrimitive lang={lang} searchParams={searchParams} />
return (
<SelectRatePagePrimitive
lang={lang}
searchParams={searchParams}
config={bookingFlowConfig}
/>
)
}

View File

@@ -1,6 +1,7 @@
import { BookingWidget } from "@scandic-hotels/booking-flow/BookingWidget"
import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/utils/url"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getDestinationCityPage } from "@/lib/trpc/memoizedRequests"
import { getLang } from "@/i18n/serverContext"
@@ -24,5 +25,7 @@ export default async function BookingWidgetDestinationCityPage(
const lang = await getLang()
return <BookingWidget booking={booking} lang={lang} />
return (
<BookingWidget booking={booking} lang={lang} config={bookingFlowConfig} />
)
}

View File

@@ -1,6 +1,7 @@
import { BookingWidget } from "@scandic-hotels/booking-flow/BookingWidget"
import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/utils/url"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getHotel, getHotelPage } from "@/lib/trpc/memoizedRequests"
import { getLang } from "@/i18n/serverContext"
@@ -36,5 +37,7 @@ export default async function BookingWidgetHotelPage(
const booking = parseBookingWidgetSearchParams(bookingWidgetSearchParams)
return <BookingWidget booking={booking} lang={lang} />
return (
<BookingWidget booking={booking} lang={lang} config={bookingFlowConfig} />
)
}

View File

@@ -1,5 +1,7 @@
import { BookingWidgetSkeleton } from "@scandic-hotels/booking-flow/BookingWidget"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
// This file is crucial for displaying a loading
// state immediately in the booking flow.
// Next doesn't recognize manually added Suspense
@@ -7,5 +9,5 @@ import { BookingWidgetSkeleton } from "@scandic-hotels/booking-flow/BookingWidge
// thus making it seem as the page is frozen during
// the time it takes for `BookingWidget` to resolve.
export default function BookingWidgetLoading() {
return <BookingWidgetSkeleton />
return <BookingWidgetSkeleton config={bookingFlowConfig} />
}

View File

@@ -1,6 +1,8 @@
import { BookingWidget } from "@scandic-hotels/booking-flow/BookingWidget"
import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/utils/url"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getLang } from "@/i18n/serverContext"
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
@@ -14,5 +16,7 @@ export default async function BookingWidgetPage(
const lang = await getLang()
return <BookingWidget booking={booking} lang={lang} />
return (
<BookingWidget booking={booking} lang={lang} config={bookingFlowConfig} />
)
}

View File

@@ -1,6 +1,8 @@
import { BookingWidget } from "@scandic-hotels/booking-flow/BookingWidget"
import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/utils/url"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import { getLang } from "@/i18n/serverContext"
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
@@ -14,5 +16,7 @@ export default async function BookingWidgetPage(
const lang = await getLang()
return <BookingWidget booking={booking} lang={lang} />
return (
<BookingWidget booking={booking} lang={lang} config={bookingFlowConfig} />
)
}

View File

@@ -9,13 +9,11 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import Script from "next/script"
import { SessionProvider } from "next-auth/react"
import { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlowConfig"
import StorageCleaner from "@scandic-hotels/booking-flow/components/EnterDetails/StorageCleaner"
import { NuqsAdapter } from "@scandic-hotels/booking-flow/utils/nuqs"
import { Lang } from "@scandic-hotels/common/constants/language"
import { ToastHandler } from "@scandic-hotels/design-system/ToastHandler"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import TrpcProvider from "@/lib/trpc/Provider"
import { SessionRefresher } from "@/components/Auth/TokenRefresher"
@@ -75,22 +73,20 @@ export default async function RootLayout(
<NuqsAdapter>
<TrpcProvider>
<RACRouterProvider>
<BookingFlowConfig config={bookingFlowConfig}>
<BookingFlowProviders>
<RouteChange />
<SitewideAlert />
<Header />
{bookingwidget}
{children}
<Footer />
<ToastHandler />
<SessionRefresher />
<StorageCleaner />
<CookieBotConsent />
<UserExists />
<ReactQueryDevtools initialIsOpen={false} />
</BookingFlowProviders>
</BookingFlowConfig>
<BookingFlowProviders>
<RouteChange />
<SitewideAlert />
<Header />
{bookingwidget}
{children}
<Footer />
<ToastHandler />
<SessionRefresher />
<StorageCleaner />
<CookieBotConsent />
<UserExists />
<ReactQueryDevtools initialIsOpen={false} />
</BookingFlowProviders>
</RACRouterProvider>
</TrpcProvider>
</NuqsAdapter>

View File

@@ -9,13 +9,11 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import Script from "next/script"
import { SessionProvider } from "next-auth/react"
import { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlowConfig"
import StorageCleaner from "@scandic-hotels/booking-flow/components/EnterDetails/StorageCleaner"
import { NuqsAdapter } from "@scandic-hotels/booking-flow/utils/nuqs"
import { Lang } from "@scandic-hotels/common/constants/language"
import { ToastHandler } from "@scandic-hotels/design-system/ToastHandler"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import TrpcProvider from "@/lib/trpc/Provider"
import { SessionRefresher } from "@/components/Auth/TokenRefresher"
@@ -59,15 +57,13 @@ export default async function RootLayout(
>
<NuqsAdapter>
<TrpcProvider>
<BookingFlowConfig config={bookingFlowConfig}>
<RouteChange />
{children}
<ToastHandler />
<SessionRefresher />
<StorageCleaner />
<CookieBotConsent />
<ReactQueryDevtools initialIsOpen={false} />
</BookingFlowConfig>
<RouteChange />
{children}
<ToastHandler />
<SessionRefresher />
<StorageCleaner />
<CookieBotConsent />
<ReactQueryDevtools initialIsOpen={false} />
</TrpcProvider>
</NuqsAdapter>
</ClientIntlProvider>

View File

@@ -8,13 +8,11 @@ import "@scandic-hotels/common/polyfills"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import Script from "next/script"
import { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlowConfig"
import StorageCleaner from "@scandic-hotels/booking-flow/components/EnterDetails/StorageCleaner"
import { NuqsAdapter } from "@scandic-hotels/booking-flow/utils/nuqs"
import { Lang } from "@scandic-hotels/common/constants/language"
import { ToastHandler } from "@scandic-hotels/design-system/ToastHandler"
import { bookingFlowConfig } from "@/constants/bookingFlowConfig"
import TrpcProvider from "@/lib/trpc/Provider"
import TokenRefresher from "@/components/Auth/TokenRefresher"
@@ -59,15 +57,13 @@ export default async function RootLayout(
>
<NuqsAdapter>
<TrpcProvider>
<BookingFlowConfig config={bookingFlowConfig}>
<RouteChange />
{children}
<ToastHandler />
<TokenRefresher />
<StorageCleaner />
<CookieBotConsent />
<ReactQueryDevtools initialIsOpen={false} />
</BookingFlowConfig>
<RouteChange />
{children}
<ToastHandler />
<TokenRefresher />
<StorageCleaner />
<CookieBotConsent />
<ReactQueryDevtools initialIsOpen={false} />
</TrpcProvider>
</NuqsAdapter>
</ClientIntlProvider>