fix: rename children to childrenInRoom

This commit is contained in:
Christel Westerberg
2025-01-14 12:25:17 +01:00
parent b2935114e3
commit bcae63e3fc
26 changed files with 104 additions and 91 deletions

View File

@@ -23,8 +23,8 @@ export default async function SelectHotelMapPage({
const {
city,
adultsInRoom,
childrenInRoomString,
childrenInRoom,
childrenInRoomArray,
selectHotelParams,
} = searchDetails
@@ -41,8 +41,8 @@ export default async function SelectHotelMapPage({
city={city}
selectHotelParams={selectHotelParams}
adultsInRoom={adultsInRoom}
childrenInRoomString={childrenInRoomString}
childrenInRoom={childrenInRoom}
child={childrenInRoomArray}
/>
</Suspense>
</MapContainer>

View File

@@ -21,8 +21,8 @@ export default async function SelectHotelPage({
city,
selectHotelParams,
adultsInRoom,
childrenInRoomString,
childrenInRoom,
childrenInRoomArray,
} = searchDetails
if (!city) return notFound()
@@ -30,13 +30,13 @@ export default async function SelectHotelPage({
const reservationParams = {
selectHotelParams,
adultsInRoom,
childrenInRoomString,
childrenInRoom,
childrenInRoomArray,
}
return (
<Suspense
key={`${city.name}-${searchParams.fromDate}-${searchParams.toDate}-${adultsInRoom}-${childrenInRoom}`}
key={`${city.name}-${searchParams.fromDate}-${searchParams.toDate}-${adultsInRoom}-${childrenInRoomString}`}
fallback={<SelectHotelSkeleton />}
>
<SelectHotel

View File

@@ -29,7 +29,7 @@ export default async function SelectRatePage({
setLang(params.lang)
const searchDetails = await getHotelSearchDetails({ searchParams })
if (!searchDetails) return notFound()
const { hotel, adultsInRoom, childrenInRoomArray, selectHotelParams } =
const { hotel, adultsInRoom, childrenInRoom, selectHotelParams } =
searchDetails
if (!hotel) return notFound()
@@ -62,9 +62,9 @@ export default async function SelectRatePage({
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
departureDate: format(departureDate, "yyyy-MM-dd"),
noOfAdults: adultsInRoom,
noOfChildren: childrenInRoomArray?.length,
ageOfChildren: childrenInRoomArray?.map((c) => c.age).join(","),
childBedPreference: childrenInRoomArray
noOfChildren: childrenInRoom?.length,
ageOfChildren: childrenInRoom?.map((c) => c.age).join(","),
childBedPreference: childrenInRoom
?.map((c) => ChildBedMapEnum[c.bed])
.join("|"),
noOfRooms: 1, // // TODO: Handle multiple rooms
@@ -88,7 +88,7 @@ export default async function SelectRatePage({
fromDate={fromDate.toDate()}
toDate={toDate.toDate()}
adultCount={adultsInRoom}
childArray={childrenInRoomArray}
childArray={childrenInRoom}
/>
<Suspense key={hotelId} fallback={<RoomsContainerSkeleton />}>
@@ -98,7 +98,7 @@ export default async function SelectRatePage({
fromDate={fromDate.toDate()}
toDate={toDate.toDate()}
adultCount={adultsInRoom}
childArray={childrenInRoomArray}
childArray={childrenInRoom}
/>
</Suspense>
<Suspense fallback={null}>

View File

@@ -64,13 +64,20 @@ export default async function StepPage({
const {
hotelId,
rooms: [
{ adults, children, roomTypeCode, rateCode, packages: packageCodes },
{
adults,
childrenInRoom,
roomTypeCode,
rateCode,
packages: packageCodes,
},
], // TODO: Handle multiple rooms
fromDate,
toDate,
} = booking
const childrenAsString = children && generateChildrenString(children)
const childrenAsString =
childrenInRoom && generateChildrenString(childrenInRoom)
const breakfastInput = { adults, fromDate, hotelId, toDate }
const selectedRoomAvailabilityInput = {
adults,
@@ -89,7 +96,7 @@ export default async function StepPage({
if (packageCodes?.length) {
void getPackages({
adults,
children: children?.length,
children: childrenInRoom?.length,
endDate: toDate,
hotelId,
packageCodes,
@@ -100,7 +107,7 @@ export default async function StepPage({
const packages = packageCodes
? await getPackages({
adults,
children: children?.length,
children: childrenInRoom?.length,
endDate: toDate,
hotelId,
packageCodes,
@@ -170,9 +177,11 @@ export default async function StepPage({
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
departureDate: format(departureDate, "yyyy-MM-dd"),
noOfAdults: adults,
noOfChildren: children?.length,
ageOfChildren: children?.map((c) => c.age).join(","),
childBedPreference: children?.map((c) => ChildBedMapEnum[c.bed]).join("|"),
noOfChildren: childrenInRoom?.length,
ageOfChildren: childrenInRoom?.map((c) => c.age).join(","),
childBedPreference: childrenInRoom
?.map((c) => ChildBedMapEnum[c.bed])
.join("|"),
noOfRooms: 1, // // TODO: Handle multiple rooms
duration: differenceInCalendarDays(departureDate, arrivalDate),
leadTime: differenceInCalendarDays(arrivalDate, new Date()),

View File

@@ -17,8 +17,8 @@ interface HotelSearchDetails<T> {
hotel: Location | null
selectHotelParams: T
adultsInRoom: number
childrenInRoom?: string
childrenInRoomArray?: Child[]
childrenInRoomString?: string
childrenInRoom?: Child[]
}
export async function getHotelSearchDetails<
@@ -48,17 +48,18 @@ export async function getHotelSearchDetails<
if (!city && !hotel) return notFound()
let adultsInRoom = 1
let childrenInRoom: string | undefined = undefined
let childrenInRoomArray: Child[] | undefined = undefined
let childrenInRoomString: HotelSearchDetails<T>["childrenInRoomString"] =
undefined
let childrenInRoom: HotelSearchDetails<T>["childrenInRoom"] = undefined
const { rooms } = selectHotelParams
if (rooms && rooms.length > 0) {
adultsInRoom = rooms[0].adults // TODO: Handle multiple rooms
childrenInRoom = rooms[0].children
? generateChildrenString(rooms[0].children)
childrenInRoomString = rooms[0].childrenInRoom
? generateChildrenString(rooms[0].childrenInRoom)
: undefined // TODO: Handle multiple rooms
childrenInRoomArray = rooms[0].children ? rooms[0].children : undefined // TODO: Handle multiple rooms
childrenInRoom = rooms[0].childrenInRoom // TODO: Handle multiple rooms
}
return {
@@ -66,7 +67,7 @@ export async function getHotelSearchDetails<
hotel: hotel ?? null,
selectHotelParams,
adultsInRoom,
childrenInRoomString,
childrenInRoom,
childrenInRoomArray,
}
}