From 4de3f4717cfc40d2623dbe7623296fca4f2e80f8 Mon Sep 17 00:00:00 2001 From: Pontus Dreij Date: Tue, 26 Nov 2024 10:27:47 +0100 Subject: [PATCH] fix(SW-978): Fallback if no room is selected in URL --- .../hotelreservation/(standard)/select-hotel/page.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) 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 3954be688..1d3ea38f6 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx @@ -61,6 +61,14 @@ export default async function SelectHotelPage({ const selectHotelParams = new URLSearchParams(searchParams) const selectHotelParamsObject = getHotelReservationQueryParams(selectHotelParams) + + if ( + !selectHotelParamsObject.room || + selectHotelParamsObject.room.length === 0 + ) { + return notFound() + } + const adults = selectHotelParamsObject.room[0].adults // TODO: Handle multiple rooms const children = selectHotelParamsObject.room[0].child ? generateChildrenString(selectHotelParamsObject.room[0].child)