Merged in feat/SW-2308-family-friends-booking-rest (pull request #1916)

feat: SW-2308 FnF code restriction added

* feat: SW-2308 FnF code restriction added

* feat: 2308 Optimized code


Approved-by: Niclas Edenvin
This commit is contained in:
Hrishikesh Vaipurkar
2025-05-02 14:22:05 +00:00
parent fb44990777
commit 53b630b6d8
10 changed files with 157 additions and 7 deletions

View File

@@ -1,8 +1,9 @@
import stringify from "json-stable-stringify-without-jsonify"
import { cookies } from "next/headers"
import { notFound } from "next/navigation"
import { Suspense } from "react"
import { REDEMPTION } from "@/constants/booking"
import { FamilyAndFriendsCodes, REDEMPTION } from "@/constants/booking"
import { getHotel } from "@/lib/trpc/memoizedRequests"
import HotelInfoCard from "@/components/HotelReservation/SelectRate/HotelInfoCard"
@@ -13,6 +14,7 @@ import { getHotelSearchDetails } from "@/utils/hotelSearchDetails"
import { convertSearchParamsToObj } from "@/utils/url"
import AvailabilityError from "./AvailabilityError"
import FnFNotAllowedAlert from "../FnFNotAllowedAlert/FnFNotAllowedAlert"
import { getValidDates } from "./getValidDates"
import { getTracking } from "./tracking"
@@ -73,17 +75,26 @@ export default async function SelectRatePage({
const booking = convertSearchParamsToObj<SelectRateSearchParams>(searchParams)
let isInValidFNF = false
if (bookingCode && FamilyAndFriendsCodes.includes(bookingCode)) {
const cookieStore = cookies()
isInValidFNF = cookieStore.get("sc")?.value !== "1"
}
const suspenseKey = stringify(searchParams)
return (
<>
<HotelInfoCard hotel={hotelData.hotel} />
<RoomsContainer
booking={booking}
hotelType={hotelData.hotel.hotelType}
roomCategories={hotelData.roomCategories}
vat={hotelData.hotel.vat}
/>
{isInValidFNF ? (
<FnFNotAllowedAlert />
) : (
<RoomsContainer
booking={booking}
hotelType={hotelData.hotel.hotelType}
roomCategories={hotelData.roomCategories}
vat={hotelData.hotel.vat}
/>
)}
<Suspense key={`${suspenseKey}-tracking`} fallback={null}>
<TrackingSDK