From 591cfc7e130f11e7cd431122c8ae3ff3a4b7dccb Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Tue, 5 Nov 2024 16:40:42 +0100 Subject: [PATCH] fix: add packages data from query param --- .../(standard)/[step]/@summary/page.tsx | 40 ++++++++++--------- .../(standard)/[step]/page.tsx | 7 ++-- .../SelectRate/RoomSelection/utils.ts | 22 ++++++---- .../enterDetails/bookingData.ts | 10 +++-- .../hotelReservation/selectRate/selectRate.ts | 1 + 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx index c145d20b3..ee900219e 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx @@ -17,9 +17,11 @@ export default async function SummaryPage({ searchParams, }: PageArgs>) { const selectRoomParams = new URLSearchParams(searchParams) - const { hotel, adults, children, roomTypeCode, rateCode, fromDate, toDate } = + const { hotel, rooms, fromDate, toDate } = getQueryParamsForEnterDetails(selectRoomParams) + const { adults, children, roomTypeCode, rateCode } = rooms[0] // TODO: Handle multiple rooms + const availability = await getSelectedRoomAvailability({ hotelId: hotel, adults, @@ -39,25 +41,25 @@ export default async function SummaryPage({ const prices = user && availability.memberRate ? { - local: { - price: availability.memberRate?.localPrice.pricePerStay, - currency: availability.memberRate?.localPrice.currency, - }, - euro: { - price: availability.memberRate?.requestedPrice?.pricePerStay, - currency: availability.memberRate?.requestedPrice?.currency, - }, - } + local: { + price: availability.memberRate?.localPrice.pricePerStay, + currency: availability.memberRate?.localPrice.currency, + }, + euro: { + price: availability.memberRate?.requestedPrice?.pricePerStay, + currency: availability.memberRate?.requestedPrice?.currency, + }, + } : { - local: { - price: availability.publicRate?.localPrice.pricePerStay, - currency: availability.publicRate?.localPrice.currency, - }, - euro: { - price: availability.publicRate?.requestedPrice?.pricePerStay, - currency: availability.publicRate?.requestedPrice?.currency, - }, - } + local: { + price: availability.publicRate?.localPrice.pricePerStay, + currency: availability.publicRate?.localPrice.currency, + }, + euro: { + price: availability.publicRate?.requestedPrice?.pricePerStay, + currency: availability.publicRate?.requestedPrice?.currency, + }, + } return ( ({ + adults: room.adults, // TODO: Handle multiple rooms + child: room.child, // TODO: Handle multiple rooms and children + roomTypeCode: room.roomtype, + rateCode: room.ratecode, + packages: room.packages?.split(",") as RoomPackageCodeEnum[], + })), } } @@ -58,11 +64,11 @@ export function createSelectRateUrl(roomData: BookingData) { const { hotel, fromDate, toDate } = roomData const params = new URLSearchParams({ fromDate, toDate, hotel }) - roomData.room.forEach((room, index) => { + roomData.rooms.forEach((room, index) => { params.set(`room[${index}].adults`, room.adults.toString()) - if (room.child) { - room.child.forEach((child, childIndex) => { + if (room.children) { + room.children.forEach((child, childIndex) => { params.set( `room[${index}].child[${childIndex}].age`, child.age.toString() diff --git a/types/components/hotelReservation/enterDetails/bookingData.ts b/types/components/hotelReservation/enterDetails/bookingData.ts index 4a6667211..720dcff3a 100644 --- a/types/components/hotelReservation/enterDetails/bookingData.ts +++ b/types/components/hotelReservation/enterDetails/bookingData.ts @@ -1,4 +1,5 @@ import { BedTypeEnum } from "../../bookingWidget/enums" +import { RoomPackageCodeEnum } from "../selectRate/roomFilter" interface Child { bed: BedTypeEnum @@ -7,15 +8,16 @@ interface Child { interface Room { adults: number - roomtype?: string - ratecode?: string - child?: Child[] + roomTypeCode: string + rateCode: string + children?: Child[] + packages?: RoomPackageCodeEnum[] } export interface BookingData { hotel: string fromDate: string toDate: string - room: Room[] + rooms: Room[] } type Price = { diff --git a/types/components/hotelReservation/selectRate/selectRate.ts b/types/components/hotelReservation/selectRate/selectRate.ts index 24a32d7d5..d1e291459 100644 --- a/types/components/hotelReservation/selectRate/selectRate.ts +++ b/types/components/hotelReservation/selectRate/selectRate.ts @@ -13,6 +13,7 @@ interface Room { ratecode: string counterratecode?: string child?: Child[] + packages?: string } export interface SelectRateSearchParams {