From bcae63e3fcb3cb2073720364731eda26d04fb0a0 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Tue, 14 Jan 2025 12:25:17 +0100 Subject: [PATCH] fix: rename children to childrenInRoom --- .../(standard)/select-hotel/map/page.tsx | 4 ++-- .../(standard)/select-hotel/page.tsx | 6 ++--- .../(standard)/select-rate/page.tsx | 12 +++++----- .../hotelreservation/(standard)/step/page.tsx | 23 +++++++++++++------ .../hotelreservation/(standard)/utils.ts | 17 +++++++------- components/BookingWidget/Client.tsx | 19 +++++++-------- .../MobileToggleButton/index.tsx | 4 ++-- components/Forms/BookingWidget/schema.ts | 8 +++---- .../ChildSelector/ChildInfoSelector.tsx | 13 ++++++----- .../GuestsRoomsPicker/ChildSelector/index.tsx | 4 ++-- components/GuestsRoomsPicker/Form.tsx | 2 +- .../GuestsRoomsPicker/GuestsRoom/index.tsx | 6 ++--- components/GuestsRoomsPicker/index.tsx | 6 ++--- .../BedType/BedTypeInfo/index.tsx | 2 +- .../EnterDetails/Breakfast/index.tsx | 2 +- .../EnterDetails/Payment/PaymentClient.tsx | 2 +- .../Summary/PriceDetailsTable/index.tsx | 6 ++--- .../EnterDetails/Summary/UI/index.tsx | 2 +- .../SelectHotelMapContainer.tsx | 13 ++++++----- .../HotelReservation/SelectHotel/index.tsx | 10 ++++---- .../bookingWidget/guestsRoomsPicker.ts | 2 +- .../hotelReservation/selectHotel/map.ts | 4 ++-- .../selectHotel/selectHotel.ts | 4 ++-- .../selectHotel/selectHotelSearchParams.ts | 4 ++-- .../hotelReservation/selectRate/selectRate.ts | 2 +- utils/url.ts | 18 +++++++-------- 26 files changed, 104 insertions(+), 91 deletions(-) diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/map/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/map/page.tsx index 9a9c357bb..e5b107781 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/map/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/map/page.tsx @@ -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} /> 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 62ec53e45..a3a1071aa 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx @@ -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 ( } > 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} /> }> @@ -98,7 +98,7 @@ export default async function SelectRatePage({ fromDate={fromDate.toDate()} toDate={toDate.toDate()} adultCount={adultsInRoom} - childArray={childrenInRoomArray} + childArray={childrenInRoom} /> diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx index 340a071ad..953c60d5b 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/page.tsx @@ -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()), diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts b/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts index 1b296d273..92ddc303c 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts @@ -17,8 +17,8 @@ interface HotelSearchDetails { 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["childrenInRoomString"] = + undefined + let childrenInRoom: HotelSearchDetails["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, } } diff --git a/components/BookingWidget/Client.tsx b/components/BookingWidget/Client.tsx index 9901b0439..bbc19a97c 100644 --- a/components/BookingWidget/Client.tsx +++ b/components/BookingWidget/Client.tsx @@ -82,15 +82,16 @@ export default function BookingWidgetClient({ ) : undefined - const defaultRoomsData = bookingWidgetSearchData?.rooms?.map((room) => ({ - adults: room.adults, - children: room.children ?? [], - })) ?? [ - { - adults: 1, - children: [], - }, - ] + const defaultRoomsData: BookingWidgetSchema["rooms"] = + bookingWidgetSearchData?.rooms?.map((room) => ({ + adults: room.adults, + childrenInRoom: room.childrenInRoom ?? [], + })) ?? [ + { + adults: 1, + childrenInRoom: [], + }, + ] const methods = useForm({ defaultValues: { diff --git a/components/BookingWidget/MobileToggleButton/index.tsx b/components/BookingWidget/MobileToggleButton/index.tsx index 54239d936..34b69a080 100644 --- a/components/BookingWidget/MobileToggleButton/index.tsx +++ b/components/BookingWidget/MobileToggleButton/index.tsx @@ -49,8 +49,8 @@ export default function MobileToggleButton({ return acc }, 0) const totalChildren = rooms.reduce((acc, room) => { - if (room.children) { - acc = acc + room.children.length + if (room.childrenInRoom) { + acc = acc + room.childrenInRoom.length } return acc }, 0) diff --git a/components/Forms/BookingWidget/schema.ts b/components/Forms/BookingWidget/schema.ts index f6bafd2d5..314ffc677 100644 --- a/components/Forms/BookingWidget/schema.ts +++ b/components/Forms/BookingWidget/schema.ts @@ -6,7 +6,7 @@ import type { Location } from "@/types/trpc/routers/hotel/locations" export const guestRoomSchema = z .object({ adults: z.number().default(1), - children: z + childrenInRoom: z .array( z.object({ age: z.number().min(0, "Age is required"), @@ -16,11 +16,11 @@ export const guestRoomSchema = z .default([]), }) .superRefine((value, ctx) => { - const childrenInAdultsBed = value.children.filter( + const childrenInAdultsBed = value.childrenInRoom.filter( (c) => c.bed === ChildBedMapEnum.IN_ADULTS_BED ) if (value.adults < childrenInAdultsBed.length) { - const lastAdultBedIndex = value.children + const lastAdultBedIndex = value.childrenInRoom .map((c) => c.bed) .lastIndexOf(ChildBedMapEnum.IN_ADULTS_BED) @@ -28,7 +28,7 @@ export const guestRoomSchema = z code: z.ZodIssueCode.custom, message: "You cannot have more children in adults bed than adults in the room", - path: ["child", lastAdultBedIndex], + path: ["childrenInRoom", lastAdultBedIndex], }) } }) diff --git a/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx b/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx index 6f4f845f3..ceac4dad7 100644 --- a/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx +++ b/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx @@ -29,8 +29,8 @@ export default function ChildInfoSelector({ index = 0, roomIndex = 0, }: ChildInfoSelectorProps) { - const ageFieldName = `rooms.${roomIndex}.children.${index}.age` - const bedFieldName = `rooms.${roomIndex}.children.${index}.bed` + const ageFieldName = `rooms.${roomIndex}.childrenInRoom.${index}.age` + const bedFieldName = `rooms.${roomIndex}.childrenInRoom.${index}.bed` const intl = useIntl() const ageLabel = intl.formatMessage({ id: "Age" }) const bedLabel = intl.formatMessage({ id: "Bed" }) @@ -38,11 +38,11 @@ export default function ChildInfoSelector({ const { setValue, formState } = useFormContext() function updateSelectedBed(bed: number) { - setValue(`rooms.${roomIndex}.children.${index}.bed`, bed) + setValue(`rooms.${roomIndex}.childrenInRoom.${index}.bed`, bed) } function updateSelectedAge(age: number) { - setValue(`rooms.${roomIndex}.children.${index}.age`, age) + setValue(`rooms.${roomIndex}.childrenInRoom.${index}.age`, age) const availableBedTypes = getAvailableBeds(age) updateSelectedBed(availableBedTypes[0].value) } @@ -76,8 +76,9 @@ export default function ChildInfoSelector({ return availableBedTypes } - //@ts-expect-error: formState is typed with FormValues - const roomErrors = formState.errors.rooms?.[roomIndex]?.children?.[index] + const roomErrors = + //@ts-expect-error: formState is typed with FormValues + formState.errors.rooms?.[roomIndex]?.childrenInRoom?.[index] const ageError = roomErrors?.age const bedError = roomErrors?.bed diff --git a/components/GuestsRoomsPicker/ChildSelector/index.tsx b/components/GuestsRoomsPicker/ChildSelector/index.tsx index b164b0ded..1ce8ffa77 100644 --- a/components/GuestsRoomsPicker/ChildSelector/index.tsx +++ b/components/GuestsRoomsPicker/ChildSelector/index.tsx @@ -24,7 +24,7 @@ export default function ChildSelector({ function increaseChildrenCount(roomIndex: number) { if (currentChildren.length < 5) { - setValue(`rooms.${roomIndex}.children.${currentChildren.length}`, { + setValue(`rooms.${roomIndex}.childrenInRoom.${currentChildren.length}`, { age: undefined, bed: undefined, }) @@ -33,7 +33,7 @@ export default function ChildSelector({ function decreaseChildrenCount(roomIndex: number) { if (currentChildren.length > 0) { currentChildren.pop() - setValue(`rooms.${roomIndex}.children`, currentChildren) + setValue(`rooms.${roomIndex}.childrenInRoom`, currentChildren) } } diff --git a/components/GuestsRoomsPicker/Form.tsx b/components/GuestsRoomsPicker/Form.tsx index da31282b5..4f0daed23 100644 --- a/components/GuestsRoomsPicker/Form.tsx +++ b/components/GuestsRoomsPicker/Form.tsx @@ -48,7 +48,7 @@ export default function GuestsRoomsPickerDialog({ }, [trigger, onClose]) const handleAddRoom = useCallback(() => { - setValue("rooms", [...roomsValue, { adults: 1, children: [] }], { + setValue("rooms", [...roomsValue, { adults: 1, childrenInRoom: [] }], { shouldValidate: true, }) }, [roomsValue, setValue]) diff --git a/components/GuestsRoomsPicker/GuestsRoom/index.tsx b/components/GuestsRoomsPicker/GuestsRoom/index.tsx index 038db6093..e6ae3bb12 100644 --- a/components/GuestsRoomsPicker/GuestsRoom/index.tsx +++ b/components/GuestsRoomsPicker/GuestsRoom/index.tsx @@ -25,7 +25,7 @@ export function GuestsRoom({ const intl = useIntl() const roomLabel = intl.formatMessage({ id: "Room" }) - const childrenInAdultsBed = room.children.filter( + const childrenInAdultsBed = room.childrenInRoom.filter( (child) => child.bed === ChildBedMapEnum.IN_ADULTS_BED ).length @@ -38,13 +38,13 @@ export function GuestsRoom({ {index !== 0 && ( diff --git a/components/GuestsRoomsPicker/index.tsx b/components/GuestsRoomsPicker/index.tsx index 7edad97d8..b92883522 100644 --- a/components/GuestsRoomsPicker/index.tsx +++ b/components/GuestsRoomsPicker/index.tsx @@ -29,7 +29,7 @@ export default function GuestsRoomsPickerForm() { const [isOpen, setIsOpen] = useState(false) const [containerHeight, setContainerHeight] = useState(0) const childCount = - rooms[0] && rooms[0].children ? rooms[0].children.length : 0 // ToDo Update for multiroom later + rooms[0] && rooms[0].childrenInRoom ? rooms[0].childrenInRoom.length : 0 // ToDo Update for multiroom later const htmlElement = typeof window !== "undefined" ? document.querySelector("body") : null @@ -154,7 +154,7 @@ function Trigger({ ) ) - if (rooms.some((room) => room.children.length > 0)) { + if (rooms.some((room) => room.childrenInRoom.length > 0)) { parts.push( intl.formatMessage( { @@ -162,7 +162,7 @@ function Trigger({ }, { totalChildren: rooms.reduce( - (acc, room) => acc + room.children.length, + (acc, room) => acc + room.childrenInRoom.length, 0 ), } diff --git a/components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx b/components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx index 641b73f01..4d39beab2 100644 --- a/components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx +++ b/components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx @@ -11,7 +11,7 @@ export default function BedTypeInfo({ hasMultipleBedTypes }: BedTypeInfoProps) { const intl = useIntl() const hasChildWithExtraBed = useEnterDetailsStore((state) => - state.booking.rooms[0].children?.some( + state.booking.rooms[0].childrenInRoom?.some( (child) => Number(child.bed) === ChildBedMapEnum.IN_EXTRA_BED ) ) diff --git a/components/HotelReservation/EnterDetails/Breakfast/index.tsx b/components/HotelReservation/EnterDetails/Breakfast/index.tsx index 141f206d0..2da0664e7 100644 --- a/components/HotelReservation/EnterDetails/Breakfast/index.tsx +++ b/components/HotelReservation/EnterDetails/Breakfast/index.tsx @@ -38,7 +38,7 @@ export default function Breakfast({ packages }: BreakfastProps) { ) const children = useEnterDetailsStore( - (state) => state.booking.rooms[0].children + (state) => state.booking.rooms[0].childrenInRoom ) const methods = useForm({ diff --git a/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx b/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx index 67a3d7f59..e55931560 100644 --- a/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx +++ b/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx @@ -239,7 +239,7 @@ export default function PaymentClient({ checkOutDate: toDate, rooms: rooms.map((room) => ({ adults: room.adults, - childrenAges: room.children?.map((child) => ({ + childrenAges: room.childrenInRoom?.map((child) => ({ age: child.age, bedType: bedTypeMap[parseInt(child.bed.toString())], })), diff --git a/components/HotelReservation/EnterDetails/Summary/PriceDetailsTable/index.tsx b/components/HotelReservation/EnterDetails/Summary/PriceDetailsTable/index.tsx index 62a5916b1..354f65038 100644 --- a/components/HotelReservation/EnterDetails/Summary/PriceDetailsTable/index.tsx +++ b/components/HotelReservation/EnterDetails/Summary/PriceDetailsTable/index.tsx @@ -66,7 +66,7 @@ export default function PriceDetailsTable({ useEnterDetailsStore(storeSelector) // TODO: Update for Multiroom later - const { adults, children } = booking.rooms[0] + const { adults, childrenInRoom } = booking.rooms[0] const nights = getNights(booking.fromDate, booking.toDate) const vatPercentage = vat / 100 @@ -121,13 +121,13 @@ export default function PriceDetailsTable({ breakfast.localPrice.currency )} /> - {children?.length ? ( + {childrenInRoom?.length ? ( { diff --git a/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx b/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx index d7877094b..d11501aa5 100644 --- a/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx +++ b/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx @@ -26,7 +26,6 @@ import { type TrackingSDKHotelInfo, type TrackingSDKPageData, } from "@/types/components/tracking" -import type { Lang } from "@/constants/languages" function isValidHotelData(hotel: NullableHotelData): hotel is HotelData { return hotel !== null && hotel !== undefined @@ -37,7 +36,7 @@ export async function SelectHotelMapContainer({ selectHotelParams, adultsInRoom, childrenInRoom, - child, + childrenInRoomString, }: SelectHotelMapContainerProps) { const lang = getLang() const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID @@ -49,7 +48,7 @@ export async function SelectHotelMapContainer({ roomStayStartDate: selectHotelParams.fromDate, roomStayEndDate: selectHotelParams.toDate, adults: adultsInRoom, - children: childrenInRoom, + children: childrenInRoomString, }) ) @@ -83,9 +82,11 @@ export async function SelectHotelMapContainer({ arrivalDate: format(arrivalDate, "yyyy-MM-dd"), departureDate: format(departureDate, "yyyy-MM-dd"), noOfAdults: adultsInRoom, - noOfChildren: child?.length, - ageOfChildren: child?.map((c) => c.age).join(","), - childBedPreference: child?.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()), diff --git a/components/HotelReservation/SelectHotel/index.tsx b/components/HotelReservation/SelectHotel/index.tsx index 85ac0b47a..566f554d9 100644 --- a/components/HotelReservation/SelectHotel/index.tsx +++ b/components/HotelReservation/SelectHotel/index.tsx @@ -48,8 +48,8 @@ export default async function SelectHotel({ const { selectHotelParams, adultsInRoom, + childrenInRoomString, childrenInRoom, - childrenInRoomArray, } = reservationParams const intl = await getIntl() @@ -60,7 +60,7 @@ export default async function SelectHotel({ roomStayStartDate: selectHotelParams.fromDate, roomStayEndDate: selectHotelParams.toDate, adults: adultsInRoom, - children: childrenInRoom, + children: childrenInRoomString, }) ) @@ -118,9 +118,9 @@ export default async function SelectHotel({ 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 diff --git a/types/components/bookingWidget/guestsRoomsPicker.ts b/types/components/bookingWidget/guestsRoomsPicker.ts index 0adbe970b..1a49768f4 100644 --- a/types/components/bookingWidget/guestsRoomsPicker.ts +++ b/types/components/bookingWidget/guestsRoomsPicker.ts @@ -5,7 +5,7 @@ export type ChildBed = { value: number } -export type TGuestsRoom = Required> +export type TGuestsRoom = Required> export type GuestsRoomPickerProps = { index: number diff --git a/types/components/hotelReservation/selectHotel/map.ts b/types/components/hotelReservation/selectHotel/map.ts index 8270742da..bd2bf0033 100644 --- a/types/components/hotelReservation/selectHotel/map.ts +++ b/types/components/hotelReservation/selectHotel/map.ts @@ -68,6 +68,6 @@ export type SelectHotelMapContainerProps = { city: Location selectHotelParams: SelectHotelSearchParams adultsInRoom: number - childrenInRoom: string | undefined - child: Child[] | undefined + childrenInRoomString: string | undefined + childrenInRoom: Child[] | undefined } diff --git a/types/components/hotelReservation/selectHotel/selectHotel.ts b/types/components/hotelReservation/selectHotel/selectHotel.ts index be91fb92e..d2443b5e0 100644 --- a/types/components/hotelReservation/selectHotel/selectHotel.ts +++ b/types/components/hotelReservation/selectHotel/selectHotel.ts @@ -48,7 +48,7 @@ export interface SelectHotelProps { reservationParams: { selectHotelParams: SelectHotelSearchParams adultsInRoom: number - childrenInRoom: string | undefined - childrenInRoomArray: Child[] | undefined + childrenInRoomString: string | undefined + childrenInRoom: Child[] | undefined } } diff --git a/types/components/hotelReservation/selectHotel/selectHotelSearchParams.ts b/types/components/hotelReservation/selectHotel/selectHotelSearchParams.ts index b269cfaf7..ee387d6d1 100644 --- a/types/components/hotelReservation/selectHotel/selectHotelSearchParams.ts +++ b/types/components/hotelReservation/selectHotel/selectHotelSearchParams.ts @@ -4,6 +4,6 @@ export interface SelectHotelSearchParams { city: string fromDate: string toDate: string - rooms: Pick[] - [key: string]: string | string[] | Pick[] + rooms: Pick[] + [key: string]: string | string[] | Pick[] } diff --git a/types/components/hotelReservation/selectRate/selectRate.ts b/types/components/hotelReservation/selectRate/selectRate.ts index 0cbb46080..cc95b3f86 100644 --- a/types/components/hotelReservation/selectRate/selectRate.ts +++ b/types/components/hotelReservation/selectRate/selectRate.ts @@ -12,7 +12,7 @@ export interface Room { roomTypeCode: string rateCode: string counterRateCode: string - children?: Child[] + childrenInRoom?: Child[] packages?: RoomPackageCodeEnum[] } diff --git a/utils/url.ts b/utils/url.ts index 1f3c540a1..732e3e348 100644 --- a/utils/url.ts +++ b/utils/url.ts @@ -26,7 +26,7 @@ const keyedSearchParams = new Map([ ["fromdate", "fromDate"], ["todate", "toDate"], ["hotel", "hotelId"], - ["child", "children"], + ["child", "childrenInRoom"], ]) export function getKeyFromSearchParam(key: string): string { @@ -71,19 +71,19 @@ export function convertSearchParamsToObj( roomObject[index].adults = Number(value) // Child is an array, so we need to handle it separately - } else if (roomObjectKey === "children") { + } else if (roomObjectKey === "childrenInRoom") { const childIndex = Number(keys[3]) const childKey = keys[4] as keyof Child if ( - !("children" in roomObject[index]) || - !Array.isArray(roomObject[index].children) + !("childrenInRoom" in roomObject[index]) || + !Array.isArray(roomObject[index].childrenInRoom) ) { - roomObject[index].children = [] + roomObject[index].childrenInRoom = [] } - roomObject[index].children![childIndex] = { - ...roomObject[index].children![childIndex], + roomObject[index].childrenInRoom![childIndex] = { + ...roomObject[index].childrenInRoom![childIndex], [childKey]: Number(value), } } else if (roomObjectKey === "packages") { @@ -115,8 +115,8 @@ export function convertObjToSearchParams( item.adults.toString() ) } - if (item?.children) { - item.children.forEach((child, childIndex) => { + if (item?.childrenInRoom) { + item.childrenInRoom.forEach((child, childIndex) => { bookingSearchParams.set( `room[${index}].child[${childIndex}].age`, child.age.toString()