50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { notFound } from "next/navigation"
|
|
import { Suspense } from "react"
|
|
|
|
import SelectHotel from "@/components/HotelReservation/SelectHotel"
|
|
import { SelectHotelSkeleton } from "@/components/HotelReservation/SelectHotel/SelectHotelSkeleton"
|
|
import { setLang } from "@/i18n/serverContext"
|
|
|
|
import { getHotelSearchDetails } from "../utils"
|
|
|
|
import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams"
|
|
import type { LangParams, PageArgs } from "@/types/params"
|
|
|
|
export default async function SelectHotelPage({
|
|
params,
|
|
searchParams,
|
|
}: PageArgs<LangParams, SelectHotelSearchParams>) {
|
|
setLang(params.lang)
|
|
const searchDetails = await getHotelSearchDetails({ searchParams })
|
|
if (!searchDetails) return notFound()
|
|
const {
|
|
city,
|
|
selectHotelParams,
|
|
adultsInRoom,
|
|
childrenInRoom,
|
|
childrenInRoomArray,
|
|
} = searchDetails
|
|
|
|
if (!city) return notFound()
|
|
|
|
const reservationParams = {
|
|
selectHotelParams,
|
|
adultsInRoom,
|
|
childrenInRoom,
|
|
childrenInRoomArray,
|
|
}
|
|
|
|
return (
|
|
<Suspense
|
|
key={`${city.name}-${searchParams.fromDate}-${searchParams.toDate}-${adultsInRoom}-${childrenInRoom}`}
|
|
fallback={<SelectHotelSkeleton />}
|
|
>
|
|
<SelectHotel
|
|
city={city}
|
|
params={params}
|
|
reservationParams={reservationParams}
|
|
/>
|
|
</Suspense>
|
|
)
|
|
}
|