Merged in feat/sw-2874-move-select-rate (pull request #2750)

Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-09-03 08:30:05 +00:00
parent 8c3f8c74db
commit f7ef58eafa
158 changed files with 708 additions and 735 deletions

View File

@@ -1,12 +1,5 @@
import { HotelInfoCardSkeleton } from "@scandic-hotels/design-system/HotelInfoCard"
import { RoomsContainerSkeleton } from "@/components/HotelReservation/SelectRate/RoomsContainer/RoomsContainerSkeleton"
import { SelectRateSkeleton } from "@scandic-hotels/booking-flow/components/SelectRate"
export default function LoadingSelectRate() {
return (
<>
<HotelInfoCardSkeleton />
<RoomsContainerSkeleton />
</>
)
return <SelectRateSkeleton />
}

View File

@@ -1,68 +1,30 @@
import { notFound } from "next/navigation"
import { SelectRatePage as SelectRatePagePrimitive } from "@scandic-hotels/booking-flow/pages/SelectRatePage"
import { SelectRateProvider } from "@scandic-hotels/booking-flow/contexts/SelectRate/SelectRateContext"
import { parseSelectRateSearchParams } from "@scandic-hotels/booking-flow/utils/url"
import { logger } from "@scandic-hotels/common/logger"
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
import TrackingSDK from "@/components/TrackingSDK"
import { getLang } from "@/i18n/serverContext"
import { combineRegExps, rateTypeRegex } from "@/constants/booking"
import { getHotel } from "@/lib/trpc/memoizedRequests"
import SelectRate from "@/components/HotelReservation/SelectRate"
import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
const singleRoomRateTypes = combineRegExps(
[rateTypeRegex.ARB, rateTypeRegex.VOUCHER],
"i"
)
import {
type LangParams,
type NextSearchParams,
type PageArgs,
} from "@/types/params"
export default async function SelectRatePage(
props: PageArgs<LangParams & { section: string }, NextSearchParams>
props: PageArgs<LangParams, NextSearchParams>
) {
const params = await props.params
const searchParams = await props.searchParams
const booking = parseSelectRateSearchParams(searchParams)
if (!booking) {
logger.debug("Invalid search params", searchParams)
notFound()
}
const isMultiRoom = booking.rooms.length > 1
const isRedemption = booking.searchType === SEARCH_TYPE_REDEMPTION
const isArbOrVoucher = booking.bookingCode
? singleRoomRateTypes.test(booking.bookingCode)
: false
if ((isMultiRoom && isRedemption) || (isMultiRoom && isArbOrVoucher)) {
logger.debug(
"Invalid search params, can't have multiroom and redemption/voucher",
{ isMultiRoom, isRedemption, isArbOrVoucher }
)
notFound()
}
// If someone tries to update the url with
// a bookingCode also, then we need to remove it
if (isRedemption && searchParams.bookingCode) {
delete searchParams.bookingCode
}
const hotelData = await getHotel({
hotelId: booking.hotelId,
isCardOnlyPayment: false,
language: params.lang,
})
if (!hotelData) {
logger.debug("Unable to find hotel data")
notFound()
}
const lang = await getLang()
return (
<SelectRateProvider hotelData={hotelData}>
<SelectRate hotelData={hotelData} booking={booking} />
</SelectRateProvider>
<SelectRatePagePrimitive
lang={lang}
searchParams={searchParams}
renderTracking={(props) => (
<TrackingSDK
hotelInfo={props.hotelsTrackingData}
pageData={props.pageTrackingData}
/>
)}
/>
)
}

View File

@@ -7,8 +7,8 @@ import "@scandic-hotels/design-system/style.css"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import Script from "next/script"
import { SessionProvider } from "next-auth/react"
import { NuqsAdapter } from "nuqs/adapters/next/app"
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"