From 78bf7ef387d3adfbd10aafdb93ebce155401b347 Mon Sep 17 00:00:00 2001 From: Pontus Dreij Date: Fri, 13 Dec 2024 13:57:44 +0100 Subject: [PATCH] fixed issue where city and hotel is undefined or null --- .../hotelreservation/(standard)/select-hotel/map/page.tsx | 5 ++++- .../hotelreservation/(standard)/select-hotel/page.tsx | 5 ++++- .../hotelreservation/(standard)/select-rate/page.tsx | 5 ++++- .../(live)/(public)/hotelreservation/(standard)/utils.ts | 8 ++++---- 4 files changed, 16 insertions(+), 7 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 2296489ac..34ae44b6f 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 @@ -1,3 +1,4 @@ +import { notFound } from "next/navigation" import { Suspense } from "react" import { SelectHotelMapContainer } from "@/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer" @@ -18,9 +19,11 @@ export default async function SelectHotelMapPage({ }: PageArgs) { setLang(params.lang) const searchDetails = await getHotelSearchDetails({ searchParams }) - if (!searchDetails) return null + if (!searchDetails) return notFound() const { city, adultsInRoom, childrenInRoom } = searchDetails + if (!city) return notFound() + return (
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 821e2d3cb..2d4aea4af 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/page.tsx @@ -1,3 +1,4 @@ +import { notFound } from "next/navigation" import { Suspense } from "react" import SelectHotel from "@/components/HotelReservation/SelectHotel" @@ -15,9 +16,11 @@ export default async function SelectHotelPage({ }: PageArgs) { setLang(params.lang) const searchDetails = await getHotelSearchDetails({ searchParams }) - if (!searchDetails) return null + if (!searchDetails) return notFound() const { city, urlSearchParams, adultsInRoom, childrenInRoom } = searchDetails + if (!city) return notFound() + const reservationParams = { selectHotelParams: urlSearchParams, searchParams, 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 c916ae231..979d370e5 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx @@ -1,3 +1,4 @@ +import { notFound } from "next/navigation" import { Suspense } from "react" import HotelInfoCard from "@/components/HotelReservation/SelectRate/HotelInfoCard" @@ -17,9 +18,11 @@ export default async function SelectRatePage({ }: PageArgs) { setLang(params.lang) const searchDetails = await getHotelSearchDetails({ searchParams }) - if (!searchDetails) return null + if (!searchDetails) return notFound() const { hotel, adultsInRoom, childrenInRoomArray } = searchDetails + if (!hotel) return notFound() + const { fromDate, toDate } = getValidDates( searchParams.fromDate, searchParams.toDate diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts b/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts index d2f9271b3..2a0ae8d42 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts @@ -15,8 +15,8 @@ import type { import type { Location } from "@/types/trpc/routers/hotel/locations" interface HotelSearchDetails { - city: Location - hotel: Location + city: Location | null + hotel: Location | null urlSearchParams?: URLSearchParams adultsInRoom: number childrenInRoom?: string @@ -67,8 +67,8 @@ export async function getHotelSearchDetails({ } return { - city: city!, - hotel: hotel!, + city: city ?? null, + hotel: hotel ?? null, urlSearchParams, adultsInRoom, childrenInRoom,