feat(SW-1717): rewrite select-rate to show all variants of rate-cards
This commit is contained in:
committed by
Michael Zetterberg
parent
adde77eaa9
commit
ebaea78fb3
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user