From 317731c24d8ca68d76bf1928ac871b81692b18c3 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Mon, 25 Nov 2024 15:04:38 +0100 Subject: [PATCH] fix: handle no children --- .../hotelreservation/(standard)/select-rate/page.tsx | 4 ++-- .../SelectRate/HotelInfoCard/NoRoomsAlert.tsx | 4 ++-- .../HotelReservation/SelectRate/HotelInfoCard/index.tsx | 2 +- .../HotelReservation/SelectRate/Rooms/RoomsContainer.tsx | 8 +++++--- 4 files changed, 10 insertions(+), 8 deletions(-) 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 a574af2d5..fa32a54cd 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx @@ -65,7 +65,7 @@ export default async function SelectRatePage({ fromDate={fromDate.toDate()} toDate={toDate.toDate()} adultCount={adults} - childArray={children ?? []} + childArray={children} /> }> @@ -75,7 +75,7 @@ export default async function SelectRatePage({ fromDate={fromDate.toDate()} toDate={toDate.toDate()} adultCount={adults} - childArray={children ?? []} + childArray={children} /> diff --git a/components/HotelReservation/SelectRate/HotelInfoCard/NoRoomsAlert.tsx b/components/HotelReservation/SelectRate/HotelInfoCard/NoRoomsAlert.tsx index 51578df8b..37653efd2 100644 --- a/components/HotelReservation/SelectRate/HotelInfoCard/NoRoomsAlert.tsx +++ b/components/HotelReservation/SelectRate/HotelInfoCard/NoRoomsAlert.tsx @@ -17,7 +17,7 @@ type Props = { hotelId: number lang: Lang adultCount: number - childArray: Child[] + childArray?: Child[] fromDate: Date toDate: Date } @@ -36,7 +36,7 @@ export async function NoRoomsAlert({ roomStayStartDate: dt(fromDate).format("YYYY-MM-DD"), roomStayEndDate: dt(toDate).format("YYYY-MM-DD"), adults: adultCount, - children: generateChildrenString(childArray), // TODO: Handle multiple rooms, + children: childArray ? generateChildrenString(childArray) : undefined, // TODO: Handle multiple rooms, }) ) diff --git a/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx b/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx index e7951c490..7c8f45e1b 100644 --- a/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx +++ b/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx @@ -27,7 +27,7 @@ type Props = { fromDate: Date toDate: Date adultCount: number - childArray: Child[] + childArray?: Child[] } export default async function HotelInfoCard({ diff --git a/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx b/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx index b32834a8a..c46ebbf25 100644 --- a/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx +++ b/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx @@ -20,7 +20,7 @@ export type Props = { fromDate: Date toDate: Date adultCount: number - childArray: Child[] + childArray?: Child[] lang: Lang } @@ -47,7 +47,7 @@ export async function RoomsContainer({ startDate: fromDateString, endDate: toDateString, adults: adultCount, - children: childArray.length > 0 ? childArray.length : undefined, + children: childArray ? childArray.length : undefined, packageCodes: [ RoomPackageCodeEnum.ACCESSIBILITY_ROOM, RoomPackageCodeEnum.PET_ROOM, @@ -63,7 +63,9 @@ export async function RoomsContainer({ roomStayEndDate: toDateString, adults: adultCount, children: - childArray.length > 0 ? generateChildrenString(childArray) : undefined, + childArray && childArray.length > 0 + ? generateChildrenString(childArray) + : undefined, }) )