fix: clean up hotel and its typings

This commit is contained in:
Simon Emanuelsson
2024-12-17 16:17:25 +01:00
parent ec74af8814
commit 13a164242f
110 changed files with 1931 additions and 1559 deletions

View File

@@ -2,7 +2,7 @@ import { differenceInCalendarDays, format, isWeekend } from "date-fns"
import { notFound } from "next/navigation"
import { Suspense } from "react"
import { getHotelData } from "@/lib/trpc/memoizedRequests"
import { getHotel } from "@/lib/trpc/memoizedRequests"
import HotelInfoCard from "@/components/HotelReservation/SelectRate/HotelInfoCard"
import { RoomsContainer } from "@/components/HotelReservation/SelectRate/Rooms/RoomsContainer"
@@ -28,13 +28,16 @@ export default async function SelectRatePage({
}: PageArgs<LangParams & { section: string }, SelectRateSearchParams>) {
setLang(params.lang)
const searchDetails = await getHotelSearchDetails({ searchParams })
if (!searchDetails) return notFound()
const { hotel, adultsInRoom, childrenInRoom, selectHotelParams } =
searchDetails
if (!searchDetails) {
return notFound()
}
const { hotel, adultsInRoom, childrenInRoom, selectHotelParams } = searchDetails
if (!hotel) return notFound()
if (!hotel) {
return notFound()
}
const hotelData = await getHotelData({
const hotelData = await getHotel({
hotelId: hotel.id,
language: params.lang,
})
@@ -72,9 +75,9 @@ export default async function SelectRatePage({
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
searchType: "hotel",
bookingTypeofDay: isWeekend(arrivalDate) ? "weekend" : "weekday",
country: hotelData?.data?.attributes.address.country,
country: hotelData?.hotel.address.country,
hotelID: hotel?.id,
region: hotelData?.data?.attributes.address.city,
region: hotelData?.hotel.address.city,
}
const hotelId = +hotel.id