fixed issue where city and hotel is undefined or null
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { notFound } from "next/navigation"
|
||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
|
|
||||||
import { SelectHotelMapContainer } from "@/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer"
|
import { SelectHotelMapContainer } from "@/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer"
|
||||||
@@ -18,9 +19,11 @@ export default async function SelectHotelMapPage({
|
|||||||
}: PageArgs<LangParams, SelectHotelSearchParams>) {
|
}: PageArgs<LangParams, SelectHotelSearchParams>) {
|
||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
const searchDetails = await getHotelSearchDetails({ searchParams })
|
const searchDetails = await getHotelSearchDetails({ searchParams })
|
||||||
if (!searchDetails) return null
|
if (!searchDetails) return notFound()
|
||||||
const { city, adultsInRoom, childrenInRoom } = searchDetails
|
const { city, adultsInRoom, childrenInRoom } = searchDetails
|
||||||
|
|
||||||
|
if (!city) return notFound()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.main}>
|
<div className={styles.main}>
|
||||||
<MapContainer>
|
<MapContainer>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { notFound } from "next/navigation"
|
||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
|
|
||||||
import SelectHotel from "@/components/HotelReservation/SelectHotel"
|
import SelectHotel from "@/components/HotelReservation/SelectHotel"
|
||||||
@@ -15,9 +16,11 @@ export default async function SelectHotelPage({
|
|||||||
}: PageArgs<LangParams, SelectHotelSearchParams>) {
|
}: PageArgs<LangParams, SelectHotelSearchParams>) {
|
||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
const searchDetails = await getHotelSearchDetails({ searchParams })
|
const searchDetails = await getHotelSearchDetails({ searchParams })
|
||||||
if (!searchDetails) return null
|
if (!searchDetails) return notFound()
|
||||||
const { city, urlSearchParams, adultsInRoom, childrenInRoom } = searchDetails
|
const { city, urlSearchParams, adultsInRoom, childrenInRoom } = searchDetails
|
||||||
|
|
||||||
|
if (!city) return notFound()
|
||||||
|
|
||||||
const reservationParams = {
|
const reservationParams = {
|
||||||
selectHotelParams: urlSearchParams,
|
selectHotelParams: urlSearchParams,
|
||||||
searchParams,
|
searchParams,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { notFound } from "next/navigation"
|
||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
|
|
||||||
import HotelInfoCard from "@/components/HotelReservation/SelectRate/HotelInfoCard"
|
import HotelInfoCard from "@/components/HotelReservation/SelectRate/HotelInfoCard"
|
||||||
@@ -17,9 +18,11 @@ export default async function SelectRatePage({
|
|||||||
}: PageArgs<LangParams & { section: string }, SelectRateSearchParams>) {
|
}: PageArgs<LangParams & { section: string }, SelectRateSearchParams>) {
|
||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
const searchDetails = await getHotelSearchDetails({ searchParams })
|
const searchDetails = await getHotelSearchDetails({ searchParams })
|
||||||
if (!searchDetails) return null
|
if (!searchDetails) return notFound()
|
||||||
const { hotel, adultsInRoom, childrenInRoomArray } = searchDetails
|
const { hotel, adultsInRoom, childrenInRoomArray } = searchDetails
|
||||||
|
|
||||||
|
if (!hotel) return notFound()
|
||||||
|
|
||||||
const { fromDate, toDate } = getValidDates(
|
const { fromDate, toDate } = getValidDates(
|
||||||
searchParams.fromDate,
|
searchParams.fromDate,
|
||||||
searchParams.toDate
|
searchParams.toDate
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import type {
|
|||||||
import type { Location } from "@/types/trpc/routers/hotel/locations"
|
import type { Location } from "@/types/trpc/routers/hotel/locations"
|
||||||
|
|
||||||
interface HotelSearchDetails {
|
interface HotelSearchDetails {
|
||||||
city: Location
|
city: Location | null
|
||||||
hotel: Location
|
hotel: Location | null
|
||||||
urlSearchParams?: URLSearchParams
|
urlSearchParams?: URLSearchParams
|
||||||
adultsInRoom: number
|
adultsInRoom: number
|
||||||
childrenInRoom?: string
|
childrenInRoom?: string
|
||||||
@@ -67,8 +67,8 @@ export async function getHotelSearchDetails({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
city: city!,
|
city: city ?? null,
|
||||||
hotel: hotel!,
|
hotel: hotel ?? null,
|
||||||
urlSearchParams,
|
urlSearchParams,
|
||||||
adultsInRoom,
|
adultsInRoom,
|
||||||
childrenInRoom,
|
childrenInRoom,
|
||||||
|
|||||||
Reference in New Issue
Block a user