diff --git a/.vscode/settings.json b/.vscode/settings.json index 25fa6215f..bb1ea9114 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.experimental.useTsgo": false } diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/page.tsx index 5e518c44f..2e9a8f84f 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/page.tsx @@ -41,8 +41,8 @@ export default async function DetailsPage( if (!booking) return notFound() - if (selectRoomParams.has("modifyRateIndex")) { - selectRoomParams.delete("modifyRateIndex") + if (selectRoomParams.has("activeRoomIndex")) { + selectRoomParams.delete("activeRoomIndex") } if ( diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate-old/loading.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate-old/loading.tsx new file mode 100644 index 000000000..8bb921599 --- /dev/null +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate-old/loading.tsx @@ -0,0 +1,16 @@ +import { HotelInfoCardSkeleton } from "@/components/HotelReservation/SelectRate/HotelInfoCard" +import { RoomsContainerSkeleton } from "@/components/HotelReservation/SelectRate/RoomsContainer/RoomsContainerSkeleton" + +// Select Rate loading doesn't need a layout and wrapper +// to force loading.tsx to show again since refetch of +// availability happens client-side and only the RoomCards +// display a loading state since we already have the hotel +// data +export default function LoadingSelectRate() { + return ( + <> + + + + ) +} diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate-old/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate-old/page.tsx new file mode 100644 index 000000000..45d483e4b --- /dev/null +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate-old/page.tsx @@ -0,0 +1,43 @@ +import { notFound } from "next/navigation" + +import { parseSelectRateSearchParams } from "@scandic-hotels/booking-flow/utils/url" +import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking" + +import { combineRegExps, rateTypeRegex } from "@/constants/booking" + +import SelectRate from "@/components/HotelReservation/SelectRate" + +import type { LangParams, NextSearchParams, PageArgs } from "@/types/params" + +const singleRoomRateTypes = combineRegExps( + [rateTypeRegex.ARB, rateTypeRegex.VOUCHER], + "i" +) + +export default async function SelectRatePage( + props: PageArgs +) { + const params = await props.params + const searchParams = await props.searchParams + const booking = parseSelectRateSearchParams(searchParams) + + if (!booking) return 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)) { + return 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 + } + + return +} diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx index 45d483e4b..c4be283b8 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx @@ -1,11 +1,14 @@ import { notFound } from "next/navigation" 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 { combineRegExps, rateTypeRegex } from "@/constants/booking" +import { getHotel } from "@/lib/trpc/memoizedRequests" -import SelectRate from "@/components/HotelReservation/SelectRate" +import SelectRate from "@/components/HotelReservation/SelectRate2" +import { SelectRateProvider } from "@/contexts/SelectRate/SelectRateContext" import type { LangParams, NextSearchParams, PageArgs } from "@/types/params" @@ -21,7 +24,10 @@ export default async function SelectRatePage( const searchParams = await props.searchParams const booking = parseSelectRateSearchParams(searchParams) - if (!booking) return notFound() + if (!booking) { + logger.debug("Invalid search params", searchParams) + notFound() + } const isMultiRoom = booking.rooms.length > 1 const isRedemption = booking.searchType === SEARCH_TYPE_REDEMPTION @@ -30,7 +36,11 @@ export default async function SelectRatePage( : false if ((isMultiRoom && isRedemption) || (isMultiRoom && isArbOrVoucher)) { - return notFound() + logger.debug( + "Invalid search params, can't have multiroom and redemption/voucher", + { isMultiRoom, isRedemption, isArbOrVoucher } + ) + notFound() } // If someone tries to update the url with @@ -39,5 +49,20 @@ export default async function SelectRatePage( delete searchParams.bookingCode } - return + const hotelData = await getHotel({ + hotelId: booking.hotelId, + isCardOnlyPayment: false, + language: params.lang, + }) + + if (!hotelData) { + logger.debug("Unable to find hotel data") + notFound() + } + + return ( + + + + ) } diff --git a/apps/scandic-web/app/[lang]/(live)/layout.tsx b/apps/scandic-web/app/[lang]/(live)/layout.tsx index 737e8285b..25c9f7d42 100644 --- a/apps/scandic-web/app/[lang]/(live)/layout.tsx +++ b/apps/scandic-web/app/[lang]/(live)/layout.tsx @@ -6,6 +6,7 @@ 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 { BookingFlowTrackingProvider } from "@scandic-hotels/booking-flow/BookingFlowTrackingProvider" import { Lang } from "@scandic-hotels/common/constants/language" @@ -65,27 +66,29 @@ export default async function RootLayout( locale={params.lang} messages={messages} > - - - - - -
- {bookingwidget} - {children} -