Fixed same string value for childBedPreference on confirmation page

This commit is contained in:
Linus Flood
2025-01-10 08:40:26 +01:00
parent 7ca2fd78f0
commit 014eea054f
5 changed files with 13 additions and 3 deletions

View File

@@ -74,7 +74,6 @@ export default async function SelectRatePage({
country: hotelData?.data?.attributes.address.country,
hotelID: hotel?.id,
region: hotelData?.data?.attributes.address.city,
//availableResults: roomCategories?.length,
//lowestRoomPrice:
}

View File

@@ -183,7 +183,6 @@ export default async function StepPage({
country: hotelAttributes?.address.country,
hotelID: hotelAttributes?.operaId,
region: hotelAttributes?.address.city,
//lowestRoomPrice:
}
const summary = {

View File

@@ -6,6 +6,7 @@ import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests"
import TrackingSDK from "@/components/TrackingSDK"
import { getLang } from "@/i18n/serverContext"
import { invertedBedTypeMap } from "../SelectRate/RoomSelection/utils"
import Confirmation from "./Confirmation"
import type { BookingConfirmationProps } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation"
@@ -43,7 +44,9 @@ export default async function BookingConfirmation({
noOfAdults: booking.adults,
noOfChildren: booking.childrenAges?.length,
ageOfChildren: booking.childrenAges?.join(","),
childBedPreference: booking?.extraBedTypes?.map((c) => c.bedType).join("|"),
childBedPreference: booking?.extraBedTypes
?.flatMap((c) => Array(c.quantity).fill(invertedBedTypeMap[c.bedType]))
.join("|"),
noOfRooms: 1, // // TODO: Handle multiple rooms
duration: differenceInCalendarDays(departureDate, arrivalDate),
leadTime: differenceInCalendarDays(arrivalDate, new Date()),

View File

@@ -22,6 +22,14 @@ export const bedTypeMap: Record<number, ChildBedTypeEnum> = {
[ChildBedMapEnum.IN_ADULTS_BED]: ChildBedTypeEnum.ParentsBed,
[ChildBedMapEnum.IN_CRIB]: ChildBedTypeEnum.Crib,
[ChildBedMapEnum.IN_EXTRA_BED]: ChildBedTypeEnum.ExtraBed,
[ChildBedMapEnum.UNKNOWN]: ChildBedTypeEnum.Unknown,
}
export const invertedBedTypeMap: Record<ChildBedTypeEnum, string> = {
[ChildBedTypeEnum.ParentsBed]: ChildBedMapEnum[ChildBedMapEnum.IN_ADULTS_BED],
[ChildBedTypeEnum.Crib]: ChildBedMapEnum[ChildBedMapEnum.IN_CRIB],
[ChildBedTypeEnum.ExtraBed]: ChildBedMapEnum[ChildBedMapEnum.IN_EXTRA_BED],
[ChildBedTypeEnum.Unknown]: ChildBedMapEnum[ChildBedMapEnum.UNKNOWN],
}
export function generateChildrenString(children: Child[]): string {

View File

@@ -2,4 +2,5 @@ export enum ChildBedMapEnum {
IN_ADULTS_BED = 0,
IN_CRIB = 1,
IN_EXTRA_BED = 2,
UNKNOWN = 3,
}