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 b28dca1a8..26b166b78 100644
--- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx
+++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx
@@ -4,7 +4,11 @@ import {
} from "@/lib/trpc/memoizedRequests"
import Summary from "@/components/HotelReservation/EnterDetails/Summary"
-import { getQueryParamsForEnterDetails } from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
+import {
+ generateChildrenString,
+ getQueryParamsForEnterDetails,
+ mapChildrenFromString,
+} from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
import { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
import { LangParams, PageArgs, SearchParams } from "@/types/params"
@@ -19,7 +23,7 @@ export default async function SummaryPage({
const availability = await getSelectedRoomAvailability({
hotelId: hotel,
adults,
- children,
+ children: children ? generateChildrenString(children) : undefined,
roomStayStartDate: fromDate,
roomStayEndDate: toDate,
rateCode,
@@ -35,25 +39,25 @@ export default async function SummaryPage({
const prices = user
? {
- 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 (
diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx
index 4f5c8f2fd..1743d07b2 100644
--- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx
+++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx
@@ -15,7 +15,10 @@ import Details from "@/components/HotelReservation/EnterDetails/Details"
import HistoryStateManager from "@/components/HotelReservation/EnterDetails/HistoryStateManager"
import Payment from "@/components/HotelReservation/EnterDetails/Payment"
import SectionAccordion from "@/components/HotelReservation/EnterDetails/SectionAccordion"
-import { getQueryParamsForEnterDetails } from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
+import {
+ generateChildrenString,
+ getQueryParamsForEnterDetails,
+} from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
import { getIntl } from "@/i18n"
import { StepEnum } from "@/types/components/hotelReservation/enterDetails/step"
@@ -49,12 +52,14 @@ export default async function StepPage({
toDate,
} = getQueryParamsForEnterDetails(selectRoomParams)
+ const childrenAsString = children && generateChildrenString(children)
+
const breakfastInput = { adults, fromDate, hotelId, toDate }
void getBreakfastPackages(breakfastInput)
void getSelectedRoomAvailability({
hotelId,
adults,
- children,
+ children: childrenAsString,
roomStayStartDate: fromDate,
roomStayEndDate: toDate,
rateCode,
@@ -69,7 +74,7 @@ export default async function StepPage({
const roomAvailability = await getSelectedRoomAvailability({
hotelId,
adults,
- children,
+ children: childrenAsString,
roomStayStartDate: fromDate,
roomStayEndDate: toDate,
rateCode,
diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx
index 5fe20e0d9..3ebe54958 100644
--- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx
+++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx
@@ -5,12 +5,14 @@ import { getLocations } from "@/lib/trpc/memoizedRequests"
import {
fetchAvailableHotels,
- generateChildrenString,
getFiltersFromHotels,
} from "@/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils"
import HotelCardListing from "@/components/HotelReservation/HotelCardListing"
import HotelFilter from "@/components/HotelReservation/SelectHotel/HotelFilter"
-import { getHotelReservationQueryParams } from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
+import {
+ generateChildrenString,
+ getHotelReservationQueryParams,
+} from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
import { ChevronRightIcon } from "@/components/Icons"
import StaticMap from "@/components/Maps/StaticMap"
import Link from "@/components/TempDesignSystem/Link"
diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts
index a6a48e12f..8dfc76a1d 100644
--- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts
+++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts
@@ -2,11 +2,9 @@ import { serverClient } from "@/lib/trpc/server"
import { getLang } from "@/i18n/serverContext"
-import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
import { AvailabilityInput } from "@/types/components/hotelReservation/selectHotel/availabilityInput"
import { HotelData } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
import { Filter } from "@/types/components/hotelReservation/selectHotel/hotelFilters"
-import { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
export async function fetchAvailableHotels(
input: AvailabilityInput
@@ -43,19 +41,3 @@ export function getFiltersFromHotels(hotels: HotelData[]) {
return filterList
}
-
-const bedTypeMap: Record = {
- [BedTypeEnum.IN_ADULTS_BED]: "ParentsBed",
- [BedTypeEnum.IN_CRIB]: "Crib",
- [BedTypeEnum.IN_EXTRA_BED]: "ExtraBed",
-}
-
-export function generateChildrenString(children: Child[]): string {
- return `[${children
- ?.map((child) => {
- const age = child.age
- const bedType = bedTypeMap[+child.bed]
- return `${age}:${bedType}`
- })
- .join(",")}]`
-}
diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx
index 1e1787d75..5a7c8617c 100644
--- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx
+++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx
@@ -7,11 +7,12 @@ import { HotelIncludeEnum } from "@/server/routers/hotels/input"
import HotelInfoCard from "@/components/HotelReservation/SelectRate/HotelInfoCard"
import Rooms from "@/components/HotelReservation/SelectRate/Rooms"
-import { getHotelReservationQueryParams } from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
+import {
+ generateChildrenString,
+ getHotelReservationQueryParams,
+} from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
import { setLang } from "@/i18n/serverContext"
-import { generateChildrenString } from "../select-hotel/utils"
-
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
import { LangParams, PageArgs } from "@/types/params"
diff --git a/components/HotelReservation/SelectRate/RoomSelection/utils.ts b/components/HotelReservation/SelectRate/RoomSelection/utils.ts
index 1fe62f39c..a087c1ce6 100644
--- a/components/HotelReservation/SelectRate/RoomSelection/utils.ts
+++ b/components/HotelReservation/SelectRate/RoomSelection/utils.ts
@@ -1,6 +1,10 @@
import { getFormattedUrlQueryParams } from "@/utils/url"
-import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
+import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
+import type {
+ Child,
+ SelectRateSearchParams,
+} from "@/types/components/hotelReservation/selectRate/selectRate"
export function getHotelReservationQueryParams(searchParams: URLSearchParams) {
return getFormattedUrlQueryParams(searchParams, {
@@ -9,6 +13,33 @@ export function getHotelReservationQueryParams(searchParams: URLSearchParams) {
}) as SelectRateSearchParams
}
+const bedTypeMap: Record = {
+ [BedTypeEnum.IN_ADULTS_BED]: "ParentsBed",
+ [BedTypeEnum.IN_CRIB]: "Crib",
+ [BedTypeEnum.IN_EXTRA_BED]: "ExtraBed",
+}
+
+export function generateChildrenString(children: Child[]): string {
+ return `[${children
+ .map((child) => {
+ const age = child.age
+ const bedType = bedTypeMap[parseInt(child.bed.toString())]
+ return `${age}:${bedType}`
+ })
+ .join(",")}]`
+}
+
+export function mapChildrenFromString(rawChildrenString: string) {
+ const children = rawChildrenString.split(",")
+ return children.map((child) => {
+ const [age, bed] = child.split(":")
+ return {
+ age: parseInt(age),
+ bed: BedTypeEnum[bed as keyof typeof BedTypeEnum],
+ }
+ })
+}
+
export function getQueryParamsForEnterDetails(searchParams: URLSearchParams) {
const selectRoomParamsObject = getHotelReservationQueryParams(searchParams)
@@ -16,7 +47,7 @@ export function getQueryParamsForEnterDetails(searchParams: URLSearchParams) {
return {
...selectRoomParamsObject,
adults: room[0].adults, // TODO: Handle multiple rooms
- children: room[0].child?.length.toString(), // TODO: Handle multiple rooms and children
+ children: room[0].child, // TODO: Handle multiple rooms and children
roomTypeCode: room[0].roomtype,
rateCode: room[0].ratecode,
}
diff --git a/types/components/hotelReservation/enterDetails/bookingData.ts b/types/components/hotelReservation/enterDetails/bookingData.ts
index 249bb466d..4a6667211 100644
--- a/types/components/hotelReservation/enterDetails/bookingData.ts
+++ b/types/components/hotelReservation/enterDetails/bookingData.ts
@@ -1,5 +1,7 @@
+import { BedTypeEnum } from "../../bookingWidget/enums"
+
interface Child {
- bed: string
+ bed: BedTypeEnum
age: number
}
diff --git a/types/components/hotelReservation/selectRate/selectRate.ts b/types/components/hotelReservation/selectRate/selectRate.ts
index 7083afa6d..24a32d7d5 100644
--- a/types/components/hotelReservation/selectRate/selectRate.ts
+++ b/types/components/hotelReservation/selectRate/selectRate.ts
@@ -1,7 +1,9 @@
import { Product, RoomConfiguration } from "@/server/routers/hotels/output"
+import { BedTypeEnum } from "../../bookingWidget/enums"
+
export interface Child {
- bed: string
+ bed: BedTypeEnum
age: number
}