feat(SW-1717): rewrite select-rate to show all variants of rate-cards

This commit is contained in:
Simon Emanuelsson
2025-03-25 11:25:44 +01:00
committed by Michael Zetterberg
parent adde77eaa9
commit ebaea78fb3
118 changed files with 4601 additions and 4374 deletions

View File

@@ -91,6 +91,7 @@ export default async function DetailsPage({
// redirect back to select-rate if availability call fails
redirect(`${selectRate(lang)}?${selectRoomParams.toString()}`)
}
rooms.push({
bedTypes: roomAvailability.bedTypes,
breakfastIncluded: roomAvailability.breakfastIncluded,
@@ -106,13 +107,7 @@ export default async function DetailsPage({
rateType: roomAvailability.rateType,
roomType: roomAvailability.selectedRoom.roomType,
roomTypeCode: roomAvailability.selectedRoom.roomTypeCode,
roomRate: {
memberRate: roomAvailability?.memberRate,
publicRate: roomAvailability.publicRate,
redemptionRate: roomAvailability.redemptionRate,
voucherRate: roomAvailability.voucherRate,
chequeRate: roomAvailability.chequeRate,
},
roomRate: roomAvailability.product,
isAvailable:
roomAvailability.selectedRoom.status === AvailabilityEnum.Available,
})

View File

@@ -9,6 +9,7 @@ import {
type TrackingSDKHotelInfo,
type TrackingSDKPageData,
} from "@/types/components/tracking"
import { CurrencyEnum } from "@/types/enums/currency"
import type { Hotel } from "@/types/hotel"
import type { Room } from "@/types/providers/details/room"
import type { Lang } from "@/constants/languages"
@@ -68,10 +69,24 @@ export function getTracking(
noOfRooms: booking.rooms.length,
rateCode: rooms
.map((room, idx) => {
if (idx === 0 && isMember && room.roomRate.memberRate) {
return room.roomRate.memberRate?.rateCode
const isMainRoom = idx === 0
if (
"member" in room.roomRate &&
room.roomRate.member &&
isMember &&
isMainRoom
) {
return room.roomRate.member.rateCode
} else if ("public" in room.roomRate && room.roomRate.public) {
return room.roomRate.public.rateCode
} else if ("corporateCheque" in room.roomRate) {
return room.roomRate.corporateCheque.rateCode
} else if ("redemption" in room.roomRate) {
return room.roomRate.redemption.rateCode
} else if ("voucher" in room.roomRate) {
return room.roomRate.voucher.rateCode
}
return room.roomRate.publicRate?.rateCode
return "-"
})
.join("|"),
rateCodeCancellationRule: rooms
@@ -81,11 +96,20 @@ export function getTracking(
rateCodeType: rooms.map((room) => room.rateType.toLowerCase()).join(","),
region: hotel?.address.city,
revenueCurrencyCode: rooms
.map(
(room) =>
room.roomRate.publicRate?.localPrice.currency ??
room.roomRate.memberRate?.localPrice.currency
)
.map((room) => {
if ("corporateCheque" in room.roomRate) {
return CurrencyEnum.CC
} else if ("redemption" in room.roomRate) {
return CurrencyEnum.POINTS
} else if ("voucher" in room.roomRate) {
return CurrencyEnum.Voucher
} else if ("public" in room.roomRate && room.roomRate.public) {
return room.roomRate.public.localPrice.currency
} else if ("member" in room.roomRate && room.roomRate.member) {
return room.roomRate.member.localPrice.currency
}
return CurrencyEnum.Unknown
})
.join(","),
searchTerm: city,
searchType: "hotel",

View File

@@ -1,9 +1,13 @@
import stringify from "json-stable-stringify-without-jsonify"
import { notFound } from "next/navigation"
import { Suspense } from "react"
import { REDEMPTION } from "@/constants/booking"
import SelectRate from "@/components/HotelReservation/SelectRate"
import { HotelInfoCardSkeleton } from "@/components/HotelReservation/SelectRate/HotelInfoCard"
import { RoomsContainerSkeleton } from "@/components/HotelReservation/SelectRate/RoomsContainer/RoomsContainerSkeleton"
import { convertSearchParamsToObj } from "@/utils/url"
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
import type { LangParams, PageArgs } from "@/types/params"
@@ -13,6 +17,17 @@ export default async function SelectRatePage({
searchParams,
}: PageArgs<LangParams & { section: string }, SelectRateSearchParams>) {
const suspenseKey = stringify(searchParams)
const booking = convertSearchParamsToObj<SelectRateSearchParams>(searchParams)
const isMultiRoom = booking.rooms.length > 1
const isRedemption = booking.searchType === REDEMPTION
const isVoucher = booking.bookingCode
? /(^VO[0-9a-z]*$)/i.test(booking.bookingCode)
: false
if ((isMultiRoom && isRedemption) || (isMultiRoom && isVoucher)) {
return notFound()
}
return (
<Suspense