From c435cdba682e5b0653b9f056e72a64dc4b05a932 Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Wed, 22 Oct 2025 07:04:21 +0000 Subject: [PATCH] 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 --- .../app/[lang]/@bookingwidget/default.tsx | 6 +- .../hotelreservation/[...paths]/loading.tsx | 4 +- apps/partner-sas/app/[lang]/debug/page.tsx | 3 +- .../booking-confirmation/page.tsx | 3 + .../payment-callback/[status]/page.tsx | 3 + .../alternative-hotels/map/page.tsx | 2 + .../(standard)/alternative-hotels/page.tsx | 7 +- .../(standard)/details/page.tsx | 10 +- .../(standard)/select-hotel/map/page.tsx | 10 +- .../(standard)/select-hotel/page.tsx | 10 +- .../(standard)/select-rate/page.tsx | 9 +- apps/partner-sas/app/[lang]/layout.tsx | 53 +++-------- apps/partner-sas/app/[lang]/page.tsx | 8 +- .../constants/bookingFlowConfig.ts | 30 ++++++ .../booking-confirmation/page.tsx | 3 + .../payment-callback/page.tsx | 3 + .../alternative-hotels/map/page.tsx | 2 + .../(standard)/alternative-hotels/page.tsx | 7 +- .../(standard)/details/page.tsx | 10 +- .../(standard)/select-hotel/map/page.tsx | 8 +- .../(standard)/select-hotel/page.tsx | 10 +- .../(standard)/select-rate/page.tsx | 9 +- .../destination_city_page/[uid]/page.tsx | 5 +- .../(contentTypes)/hotel_page/[uid]/page.tsx | 5 +- .../hotelreservation/[...paths]/loading.tsx | 4 +- .../@bookingwidget/hotelreservation/page.tsx | 6 +- .../app/[lang]/(live)/@bookingwidget/page.tsx | 6 +- apps/scandic-web/app/[lang]/(live)/layout.tsx | 32 +++---- .../app/[lang]/(no-layout)/layout.tsx | 18 ++-- .../app/[lang]/(partner)/layout.tsx | 18 ++-- .../ContentType/StartPage/index.tsx | 7 +- .../lib/components/BookingWidget/Client.tsx | 6 +- .../FloatingBookingWidget/index.tsx | 12 ++- .../lib/components/BookingWidget/Skeleton.tsx | 8 +- .../lib/components/BookingWidget/index.tsx | 14 ++- .../lib/pages/AlternativeHotelsMapPage.tsx | 44 +++++---- .../lib/pages/AlternativeHotelsPage.tsx | 10 +- .../lib/pages/BookingConfirmationPage.tsx | 15 ++- .../lib/pages/EnterDetailsPage.tsx | 95 ++++++++++--------- .../lib/pages/PaymentCallbackPage.tsx | 45 +++++---- .../lib/pages/SelectHotelMapPage.tsx | 42 ++++---- .../lib/pages/SelectHotelPage.tsx | 10 +- .../booking-flow/lib/pages/SelectRatePage.tsx | 7 +- .../trpc/lib/utils/getUserPointsBalance.ts | 16 +++- 44 files changed, 398 insertions(+), 237 deletions(-) create mode 100644 apps/partner-sas/constants/bookingFlowConfig.ts diff --git a/apps/partner-sas/app/[lang]/@bookingwidget/default.tsx b/apps/partner-sas/app/[lang]/@bookingwidget/default.tsx index c0e9476f2..99f9ec2a2 100644 --- a/apps/partner-sas/app/[lang]/@bookingwidget/default.tsx +++ b/apps/partner-sas/app/[lang]/@bookingwidget/default.tsx @@ -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, PageArgs } from "@/types/params" @@ -12,5 +14,7 @@ export default async function BookingWidgetPage(props: PageArgs) { const lang = await getLang() - return + return ( + + ) } diff --git a/apps/partner-sas/app/[lang]/@bookingwidget/hotelreservation/[...paths]/loading.tsx b/apps/partner-sas/app/[lang]/@bookingwidget/hotelreservation/[...paths]/loading.tsx index e06bc80f5..b8f33bf74 100644 --- a/apps/partner-sas/app/[lang]/@bookingwidget/hotelreservation/[...paths]/loading.tsx +++ b/apps/partner-sas/app/[lang]/@bookingwidget/hotelreservation/[...paths]/loading.tsx @@ -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 + return } diff --git a/apps/partner-sas/app/[lang]/debug/page.tsx b/apps/partner-sas/app/[lang]/debug/page.tsx index a69552e70..b1165be24 100644 --- a/apps/partner-sas/app/[lang]/debug/page.tsx +++ b/apps/partner-sas/app/[lang]/debug/page.tsx @@ -2,6 +2,7 @@ import { BookingWidget } from "@scandic-hotels/booking-flow/BookingWidget" import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/utils/url" import { Typography } from "@scandic-hotels/design-system/Typography" +import { bookingFlowConfig } from "@/constants/bookingFlowConfig" import { serverClient } from "@/lib/trpc" import { getIntl } from "@/i18n" @@ -33,7 +34,7 @@ export default async function Debug(props: SearchParams) { {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}

from booking-flow package:

- +
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(confirmation)/booking-confirmation/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(confirmation)/booking-confirmation/page.tsx index 54f0f1650..5e3512650 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(confirmation)/booking-confirmation/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(confirmation)/booking-confirmation/page.tsx @@ -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} /> ) } diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(payment-callback)/payment-callback/[status]/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(payment-callback)/payment-callback/[status]/page.tsx index 57d7c9702..1c5d13540 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(payment-callback)/payment-callback/[status]/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(payment-callback)/payment-callback/[status]/page.tsx @@ -1,6 +1,8 @@ import { PaymentCallbackPage as PaymentCallbackPagePrimitive } from "@scandic-hotels/booking-flow/pages/PaymentCallbackPage" import { logger } from "@scandic-hotels/common/logger" +import { bookingFlowConfig } from "@/constants/bookingFlowConfig" + import type { PaymentCallbackStatusEnum } from "@scandic-hotels/common/constants/paymentCallbackStatusEnum" import type { LangParams, PageArgs } from "@/types/params" @@ -26,6 +28,7 @@ export default async function PaymentCallbackPage( userAccessToken={userAccessToken} searchParams={searchParams} status={params.status as PaymentCallbackStatusEnum} + config={bookingFlowConfig} /> ) } diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/map/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/map/page.tsx index f534bd1ed..9ab05e1df 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/map/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/map/page.tsx @@ -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/getHotel" import { getIntl } from "@/i18n" @@ -56,6 +57,7 @@ export default async function AlternativeHotelsMapPage( ) diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/page.tsx index 51d625b96..341d7d9f5 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/alternative-hotels/page.tsx @@ -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/getHotel" import { getIntl } from "@/i18n" @@ -52,6 +53,10 @@ export default async function AlternativeHotelsPage( const lang = await getLang() return ( - + ) } diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/details/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/details/page.tsx index 3b5df1964..4a0688cd8 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/details/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/details/page.tsx @@ -1,10 +1,18 @@ import { EnterDetailsPage as EnterDetailsPagePrimitive } from "@scandic-hotels/booking-flow/pages/EnterDetailsPage" +import { bookingFlowConfig } from "@/constants/bookingFlowConfig" + import type { LangParams, PageArgs } from "@/types/params" export default async function DetailsPage(props: PageArgs) { const { lang } = await props.params const searchParams = await props.searchParams - return + return ( + + ) } diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/map/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/map/page.tsx index 970e95c7e..5433dacfd 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/map/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/map/page.tsx @@ -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 type { Metadata } from "next" @@ -25,5 +27,11 @@ export default async function SelectHotelMapPage(props: PageArgs) { const searchParams = await props.searchParams const lang = await getLang() - return + return ( + + ) } diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/page.tsx index c7def4927..42485fc53 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-hotel/page.tsx @@ -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" @@ -25,5 +27,11 @@ export default async function SelectHotelPage(props: PageArgs) { const searchParams = await props.searchParams const lang = await getLang() - return + return ( + + ) } diff --git a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-rate/page.tsx b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-rate/page.tsx index 6816f1b02..a8766ee08 100644 --- a/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-rate/page.tsx +++ b/apps/partner-sas/app/[lang]/hotelreservation/(standard)/select-rate/page.tsx @@ -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/getHotel" import { getLang } from "@/i18n/serverContext" @@ -38,5 +39,11 @@ export default async function SelectRatePage(props: PageArgs) { const searchParams = await props.searchParams const lang = await getLang() - return + return ( + + ) } diff --git a/apps/partner-sas/app/[lang]/layout.tsx b/apps/partner-sas/app/[lang]/layout.tsx index b5024fe8f..3ad3d62b6 100644 --- a/apps/partner-sas/app/[lang]/layout.tsx +++ b/apps/partner-sas/app/[lang]/layout.tsx @@ -8,13 +8,8 @@ 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 { NuqsAdapter } from "@scandic-hotels/booking-flow/utils/nuqs" import { Lang } from "@scandic-hotels/common/constants/language" -import { bookingTermsAndConditionsRoutes } from "@scandic-hotels/common/constants/routes/bookingTermsAndConditionsRoutes" -import { customerService } from "@scandic-hotels/common/constants/routes/customerService" -import { myStay } from "@scandic-hotels/common/constants/routes/myStay" -import { privacyPolicyRoutes } from "@scandic-hotels/common/constants/routes/privacyPolicyRoutes" import { ToastHandler } from "@scandic-hotels/design-system/ToastHandler" import AdobeSDKScript from "@/components/AdobeSDKScript" @@ -34,8 +29,6 @@ import { Footer } from "../../components/Footer/Footer" import { Header } from "../../components/Header/Header" import { SocialLoginProvider } from "./(auth)/SocialLogin" -import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute" - type LangParams = { lang: Lang } @@ -55,20 +48,6 @@ export default async function RootLayout(props: RootLayoutProps) { const parsedLanguage = setLang(lang) const messages = await getMessages(parsedLanguage) - const bookingFlowConfig: BookingFlowConfig = { - bookingCodeEnabled: false, - enterDetailsMembershipIdInputLocation: "join-card", - variant: "partner-sas", - routes: { - myStay: routeToScandicWeb(myStay), - bookingTermsAndConditions: routeToScandicWeb( - bookingTermsAndConditionsRoutes - ), - customerService: routeToScandicWeb(customerService), - privacyPolicy: routeToScandicWeb(privacyPolicyRoutes), - }, - } - return ( @@ -93,19 +72,17 @@ export default async function RootLayout(props: RootLayoutProps) { - - - - -
- {props.bookingwidget} -
{children}
-