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:
@@ -5,7 +5,7 @@ import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
|
||||
|
||||
import { env } from "../../env/server"
|
||||
import { getBookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { MapContainer } from "../components/MapContainer"
|
||||
import {
|
||||
getFiltersFromHotels,
|
||||
@@ -27,9 +27,11 @@ import type { NextSearchParams } from "../types"
|
||||
export async function AlternativeHotelsMapPage({
|
||||
lang,
|
||||
searchParams,
|
||||
config,
|
||||
}: {
|
||||
lang: Lang
|
||||
searchParams: NextSearchParams
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID
|
||||
const googleMapsApiKey = env.GOOGLE_STATIC_MAP_KEY
|
||||
@@ -103,29 +105,31 @@ export async function AlternativeHotelsMapPage({
|
||||
isBookingCodeRateAvailable,
|
||||
isRedemption: redemption,
|
||||
isRedemptionAvailable: isRedemptionAvailability,
|
||||
config: getBookingFlowConfig(),
|
||||
config,
|
||||
})
|
||||
|
||||
const filterList = getFiltersFromHotels(hotels, isBookingCodeRateAvailable)
|
||||
|
||||
return (
|
||||
<MapContainer>
|
||||
<Suspense key={booking.hotelId} fallback={<SelectHotelMapSkeleton />}>
|
||||
<SelectHotelMap
|
||||
apiKey={googleMapsApiKey}
|
||||
mapId={googleMapId}
|
||||
hotels={hotels}
|
||||
cityCoordinates={cityCoordinates}
|
||||
bookingCode={booking.bookingCode}
|
||||
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
||||
isAlternativeHotels={true}
|
||||
filterList={filterList}
|
||||
/>
|
||||
<TrackingSDK
|
||||
hotelInfo={hotelsTrackingData}
|
||||
pageData={pageTrackingData}
|
||||
/>
|
||||
</Suspense>
|
||||
</MapContainer>
|
||||
<BookingFlowConfig config={config}>
|
||||
<MapContainer>
|
||||
<Suspense key={booking.hotelId} fallback={<SelectHotelMapSkeleton />}>
|
||||
<SelectHotelMap
|
||||
apiKey={googleMapsApiKey}
|
||||
mapId={googleMapId}
|
||||
hotels={hotels}
|
||||
cityCoordinates={cityCoordinates}
|
||||
bookingCode={booking.bookingCode}
|
||||
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
||||
isAlternativeHotels={true}
|
||||
filterList={filterList}
|
||||
/>
|
||||
<TrackingSDK
|
||||
hotelInfo={hotelsTrackingData}
|
||||
pageData={pageTrackingData}
|
||||
/>
|
||||
</Suspense>
|
||||
</MapContainer>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { FamilyAndFriendsCodes } from "@scandic-hotels/common/constants/familyAn
|
||||
import { NoAvailabilityTracking } from "@scandic-hotels/tracking/NoAvailabilityTracking"
|
||||
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
|
||||
|
||||
import { getBookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { AlternativeHotelsPageTitle } from "../components/AlternativeHotelsPageTitle"
|
||||
import FnFNotAllowedAlert from "../components/FnFNotAllowedAlert"
|
||||
import { SelectHotel } from "../components/SelectHotel"
|
||||
@@ -25,9 +25,11 @@ export { SelectHotelSkeleton as AlternativeHotelsPageSkeleton } from "../compone
|
||||
export async function AlternativeHotelsPage({
|
||||
lang,
|
||||
searchParams,
|
||||
config,
|
||||
}: {
|
||||
lang: Lang
|
||||
searchParams: NextSearchParams
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const booking = parseSelectHotelSearchParams(searchParams)
|
||||
|
||||
@@ -108,7 +110,7 @@ export async function AlternativeHotelsPage({
|
||||
isBookingCodeRateAvailable,
|
||||
isRedemption: searchDetails.redemption,
|
||||
isRedemptionAvailable: isRedemptionAvailability,
|
||||
config: getBookingFlowConfig(),
|
||||
config,
|
||||
})
|
||||
|
||||
const suspenseKey = stringify(searchParams)
|
||||
@@ -118,7 +120,7 @@ export async function AlternativeHotelsPage({
|
||||
(booking.bookingCode && hotels.length > 0 && !isBookingCodeRateAvailable)
|
||||
)
|
||||
return (
|
||||
<>
|
||||
<BookingFlowConfig config={config}>
|
||||
<SelectHotel
|
||||
bookingCode={booking.bookingCode}
|
||||
city={searchDetails.city}
|
||||
@@ -142,6 +144,6 @@ export async function AlternativeHotelsPage({
|
||||
shouldTrackNoAvailability={shouldTrackNoAvailability}
|
||||
/>
|
||||
</Suspense>
|
||||
</>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { notFound, redirect } from "next/navigation"
|
||||
|
||||
import { decrypt } from "@scandic-hotels/trpc/utils/encryption"
|
||||
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { BookingConfirmation } from "../components/BookingConfirmation"
|
||||
import { getBookingConfirmation } from "../trpc/memoizedRequests/getBookingConfirmation"
|
||||
import { MEMBERSHIP_FAILED_ERROR } from "../types/membershipFailedError"
|
||||
@@ -16,10 +17,12 @@ export async function BookingConfirmationPage({
|
||||
intl,
|
||||
lang,
|
||||
searchParams,
|
||||
config,
|
||||
}: {
|
||||
intl: IntlShape
|
||||
lang: Lang
|
||||
searchParams: NextSearchParams
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const refId = searchParams.RefId?.toString()
|
||||
|
||||
@@ -46,10 +49,12 @@ export async function BookingConfirmationPage({
|
||||
searchParams.errorCode === MEMBERSHIP_FAILED_ERROR
|
||||
|
||||
return (
|
||||
<BookingConfirmation
|
||||
intl={intl}
|
||||
refId={refId}
|
||||
membershipFailedError={membershipFailedError}
|
||||
/>
|
||||
<BookingFlowConfig config={config}>
|
||||
<BookingConfirmation
|
||||
intl={intl}
|
||||
refId={refId}
|
||||
membershipFailedError={membershipFailedError}
|
||||
/>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Suspense } from "react"
|
||||
|
||||
import { FamilyAndFriendsCodes } from "@scandic-hotels/common/constants/familyAndFriends"
|
||||
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import HotelHeader from "../components/EnterDetails/Header"
|
||||
import Payment from "../components/EnterDetails/Payment"
|
||||
import Multiroom from "../components/EnterDetails/Room/Multiroom"
|
||||
@@ -29,9 +30,11 @@ import type { NextSearchParams } from "../types"
|
||||
export async function EnterDetailsPage({
|
||||
lang,
|
||||
searchParams,
|
||||
config,
|
||||
}: {
|
||||
lang: Lang
|
||||
searchParams: NextSearchParams
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const selectRoomParams = new URLSearchParams(
|
||||
searchParams as Record<string, string>
|
||||
@@ -116,53 +119,55 @@ export async function EnterDetailsPage({
|
||||
// beneath footer to be able to show entire footer upon
|
||||
// scrolling down to the bottom of the page
|
||||
return (
|
||||
<main data-footer-spacing>
|
||||
<EnterDetailsProvider
|
||||
booking={booking}
|
||||
breakfastPackages={breakfastPackages}
|
||||
lang={lang}
|
||||
rooms={rooms}
|
||||
searchParamsStr={selectRoomParams.toString()}
|
||||
user={user}
|
||||
vat={hotel.vat}
|
||||
roomCategories={hotelData.roomCategories}
|
||||
>
|
||||
<HotelHeader hotelData={hotelData} />
|
||||
<div className={styles.container}>
|
||||
<div className={styles.content}>
|
||||
<RoomProvider idx={0} room={firstRoom}>
|
||||
<RoomOne user={user} />
|
||||
</RoomProvider>
|
||||
{multirooms.map((room, idx) => (
|
||||
// Need to start idx from 1 since first room is
|
||||
// rendered above
|
||||
<RoomProvider key={idx + 1} idx={idx + 1} room={room}>
|
||||
<Multiroom />
|
||||
</RoomProvider>
|
||||
))}
|
||||
<Suspense>
|
||||
<Payment
|
||||
otherPaymentOptions={
|
||||
hotel.merchantInformationData.alternatePaymentOptions
|
||||
}
|
||||
supportedCards={hotel.merchantInformationData.cards}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
<aside className={styles.summary}>
|
||||
<MobileSummary isUserLoggedIn={!!user} />
|
||||
<DesktopSummary isUserLoggedIn={!!user} />
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<EnterDetailsTrackingWrapper
|
||||
<BookingFlowConfig config={config}>
|
||||
<main data-footer-spacing>
|
||||
<EnterDetailsProvider
|
||||
booking={booking}
|
||||
hotel={hotel}
|
||||
isMember={!!user}
|
||||
breakfastPackages={breakfastPackages}
|
||||
lang={lang}
|
||||
rooms={rooms}
|
||||
/>
|
||||
</EnterDetailsProvider>
|
||||
</main>
|
||||
searchParamsStr={selectRoomParams.toString()}
|
||||
user={user}
|
||||
vat={hotel.vat}
|
||||
roomCategories={hotelData.roomCategories}
|
||||
>
|
||||
<HotelHeader hotelData={hotelData} />
|
||||
<div className={styles.container}>
|
||||
<div className={styles.content}>
|
||||
<RoomProvider idx={0} room={firstRoom}>
|
||||
<RoomOne user={user} />
|
||||
</RoomProvider>
|
||||
{multirooms.map((room, idx) => (
|
||||
// Need to start idx from 1 since first room is
|
||||
// rendered above
|
||||
<RoomProvider key={idx + 1} idx={idx + 1} room={room}>
|
||||
<Multiroom />
|
||||
</RoomProvider>
|
||||
))}
|
||||
<Suspense>
|
||||
<Payment
|
||||
otherPaymentOptions={
|
||||
hotel.merchantInformationData.alternatePaymentOptions
|
||||
}
|
||||
supportedCards={hotel.merchantInformationData.cards}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
<aside className={styles.summary}>
|
||||
<MobileSummary isUserLoggedIn={!!user} />
|
||||
<DesktopSummary isUserLoggedIn={!!user} />
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<EnterDetailsTrackingWrapper
|
||||
booking={booking}
|
||||
hotel={hotel}
|
||||
isMember={!!user}
|
||||
lang={lang}
|
||||
rooms={rooms}
|
||||
/>
|
||||
</EnterDetailsProvider>
|
||||
</main>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCod
|
||||
import { getBooking } from "@scandic-hotels/trpc/routers/booking/utils"
|
||||
import { encrypt } from "@scandic-hotels/trpc/utils/encryption"
|
||||
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { HandleErrorCallback } from "../components/EnterDetails/Payment/PaymentCallback/HandleErrorCallback"
|
||||
import { HandleSuccessCallback } from "../components/EnterDetails/Payment/PaymentCallback/HandleSuccessCallback"
|
||||
import { serverClient } from "../trpc"
|
||||
@@ -24,12 +25,14 @@ type PaymentCallbackPageProps = {
|
||||
searchParams: NextSearchParams
|
||||
userAccessToken: string | null
|
||||
status: PaymentCallbackStatusEnum
|
||||
config: BookingFlowConfig
|
||||
}
|
||||
export async function PaymentCallbackPage({
|
||||
lang,
|
||||
userAccessToken,
|
||||
searchParams,
|
||||
status,
|
||||
config,
|
||||
}: PaymentCallbackPageProps) {
|
||||
const { confirmationNumber } = searchParams
|
||||
|
||||
@@ -51,12 +54,14 @@ export async function PaymentCallbackPage({
|
||||
if (status === PaymentCallbackStatusEnum.Cancel) {
|
||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionCancelled)
|
||||
return (
|
||||
<HandleErrorCallback
|
||||
returnUrl={returnUrl.toString()}
|
||||
searchObject={searchObject}
|
||||
status={status}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
<BookingFlowConfig config={config}>
|
||||
<HandleErrorCallback
|
||||
returnUrl={returnUrl.toString()}
|
||||
searchObject={searchObject}
|
||||
status={status}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -92,12 +97,14 @@ export async function PaymentCallbackPage({
|
||||
)
|
||||
|
||||
return (
|
||||
<HandleSuccessCallback
|
||||
refId={refId}
|
||||
sig={sig}
|
||||
successRedirectUrl={confirmationUrl}
|
||||
cardType={booking.guaranteeInfo?.cardType}
|
||||
/>
|
||||
<BookingFlowConfig config={config}>
|
||||
<HandleSuccessCallback
|
||||
refId={refId}
|
||||
sig={sig}
|
||||
successRedirectUrl={confirmationUrl}
|
||||
cardType={booking.guaranteeInfo?.cardType}
|
||||
/>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -141,11 +148,13 @@ export async function PaymentCallbackPage({
|
||||
}
|
||||
|
||||
return (
|
||||
<HandleErrorCallback
|
||||
returnUrl={returnUrl.toString()}
|
||||
searchObject={searchObject}
|
||||
status={status}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
<BookingFlowConfig config={config}>
|
||||
<HandleErrorCallback
|
||||
returnUrl={returnUrl.toString()}
|
||||
searchObject={searchObject}
|
||||
status={status}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
|
||||
|
||||
import { env } from "../../env/server"
|
||||
import { getBookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { MapContainer } from "../components/MapContainer"
|
||||
import {
|
||||
getFiltersFromHotels,
|
||||
@@ -28,9 +28,11 @@ import type { NextSearchParams } from "../types"
|
||||
export async function SelectHotelMapPage({
|
||||
lang,
|
||||
searchParams,
|
||||
config,
|
||||
}: {
|
||||
lang: Lang
|
||||
searchParams: NextSearchParams
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID
|
||||
const googleMapsApiKey = env.GOOGLE_STATIC_MAP_KEY
|
||||
@@ -104,7 +106,7 @@ export async function SelectHotelMapPage({
|
||||
isBookingCodeRateAvailable,
|
||||
isRedemption: redemption,
|
||||
isRedemptionAvailable: isRedemptionAvailability,
|
||||
config: getBookingFlowConfig(),
|
||||
config,
|
||||
})
|
||||
|
||||
const filterList = getFiltersFromHotels(hotels, isBookingCodeRateAvailable)
|
||||
@@ -112,22 +114,24 @@ export async function SelectHotelMapPage({
|
||||
const suspenseKey = stringify(searchParams)
|
||||
|
||||
return (
|
||||
<MapContainer>
|
||||
<Suspense key={suspenseKey} fallback={<SelectHotelMapSkeleton />}>
|
||||
<SelectHotelMap
|
||||
apiKey={googleMapsApiKey}
|
||||
mapId={googleMapId}
|
||||
hotels={hotels}
|
||||
cityCoordinates={cityCoordinates}
|
||||
bookingCode={booking.bookingCode}
|
||||
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
||||
filterList={filterList}
|
||||
/>
|
||||
<TrackingSDK
|
||||
hotelInfo={hotelsTrackingData}
|
||||
pageData={pageTrackingData}
|
||||
/>
|
||||
</Suspense>
|
||||
</MapContainer>
|
||||
<BookingFlowConfig config={config}>
|
||||
<MapContainer>
|
||||
<Suspense key={suspenseKey} fallback={<SelectHotelMapSkeleton />}>
|
||||
<SelectHotelMap
|
||||
apiKey={googleMapsApiKey}
|
||||
mapId={googleMapId}
|
||||
hotels={hotels}
|
||||
cityCoordinates={cityCoordinates}
|
||||
bookingCode={booking.bookingCode}
|
||||
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
||||
filterList={filterList}
|
||||
/>
|
||||
<TrackingSDK
|
||||
hotelInfo={hotelsTrackingData}
|
||||
pageData={pageTrackingData}
|
||||
/>
|
||||
</Suspense>
|
||||
</MapContainer>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { FamilyAndFriendsCodes } from "@scandic-hotels/common/constants/familyAn
|
||||
import { NoAvailabilityTracking } from "@scandic-hotels/tracking/NoAvailabilityTracking"
|
||||
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
|
||||
|
||||
import { getBookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import FnFNotAllowedAlert from "../components/FnFNotAllowedAlert"
|
||||
import { SelectHotel } from "../components/SelectHotel"
|
||||
import { getHotels } from "../components/SelectHotel/helpers"
|
||||
@@ -24,9 +24,11 @@ export { SelectHotelSkeleton as SelectHotelPageSkeleton } from "../components/Se
|
||||
export async function SelectHotelPage({
|
||||
lang,
|
||||
searchParams,
|
||||
config,
|
||||
}: {
|
||||
lang: Lang
|
||||
searchParams: NextSearchParams
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const booking = parseSelectHotelSearchParams(searchParams)
|
||||
|
||||
@@ -94,7 +96,7 @@ export async function SelectHotelPage({
|
||||
isBookingCodeRateAvailable,
|
||||
isRedemption: redemption,
|
||||
isRedemptionAvailable: isRedemptionAvailability,
|
||||
config: getBookingFlowConfig(),
|
||||
config,
|
||||
})
|
||||
|
||||
const suspenseKey = stringify(searchParams)
|
||||
@@ -105,7 +107,7 @@ export async function SelectHotelPage({
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<BookingFlowConfig config={config}>
|
||||
<SelectHotel
|
||||
bookingCode={booking.bookingCode}
|
||||
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
||||
@@ -126,6 +128,6 @@ export async function SelectHotelPage({
|
||||
shouldTrackNoAvailability={shouldTrackNoAvailability}
|
||||
/>
|
||||
</Suspense>
|
||||
</>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { notFound } from "next/navigation"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
|
||||
import { SelectRate } from "../components/SelectRate"
|
||||
import { SelectRateTracking } from "../components/SelectRate/Tracking/SelectRateTracking"
|
||||
import { SelectRateProvider } from "../contexts/SelectRate/SelectRateContext"
|
||||
@@ -28,9 +29,11 @@ const singleRoomRateTypes = combineRegExps(
|
||||
export async function SelectRatePage({
|
||||
lang,
|
||||
searchParams,
|
||||
config,
|
||||
}: {
|
||||
lang: Lang
|
||||
searchParams: NextSearchParams
|
||||
config: BookingFlowConfig
|
||||
}) {
|
||||
const booking = parseSelectRateSearchParams(searchParams)
|
||||
|
||||
@@ -71,12 +74,12 @@ export async function SelectRatePage({
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<BookingFlowConfig config={config}>
|
||||
<SelectRateProvider hotelData={hotelData}>
|
||||
<SelectRate hotelData={hotelData} booking={booking} />
|
||||
<SelectRateTracking hotelData={hotelData} booking={booking} />
|
||||
</SelectRateProvider>
|
||||
</>
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user