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 7557a4b59..a574af2d5 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-rate/page.tsx @@ -1,7 +1,6 @@ import { notFound } from "next/navigation" import { Suspense } from "react" -import { dt } from "@/lib/dt" import { getHotelData, getLocations } from "@/lib/trpc/memoizedRequests" import HotelInfoCard from "@/components/HotelReservation/SelectRate/HotelInfoCard" @@ -11,6 +10,8 @@ import { getHotelReservationQueryParams } from "@/components/HotelReservation/Se import { setLang } from "@/i18n/serverContext" import { safeTry } from "@/utils/safeTry" +import { getValidDates } from "./getValidDates" + import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate" import type { LangParams, PageArgs } from "@/types/params" @@ -39,15 +40,10 @@ export default async function SelectRatePage({ return notFound() } - const fromDate = - searchParams.fromDate && - dt(searchParams.fromDate).isAfter(dt().subtract(1, "day")) - ? dt(searchParams.fromDate) - : dt().utc() - const toDate = - searchParams.toDate && dt(searchParams.toDate).isAfter(fromDate) - ? dt(searchParams.toDate) - : dt().utc().add(1, "day") + const { fromDate, toDate } = getValidDates( + searchParams.fromDate, + searchParams.toDate + ) const adults = selectRoomParamsObject.room[0].adults || 1 // TODO: Handle multiple rooms const children = selectRoomParamsObject.room[0].child // TODO: Handle multiple rooms diff --git a/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx b/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx index 94d8031f1..b32834a8a 100644 --- a/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx +++ b/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx @@ -73,16 +73,19 @@ export async function RoomsContainer({ await roomsAvailabilityPromise if (packagesError) { - console.error("packagesError", packagesError) - - return ( -
Unable to get packages. {JSON.stringify({ ...packagesError })}
- ) + // TODO: Log packages error + console.error("[RoomsContainer] unable to fetch packages") } - if (roomsAvailabilityError || !roomsAvailability) { - console.error("roomsAvailabilityError", roomsAvailabilityError) - return
Unable to get room availability
+ if (roomsAvailabilityError) { + // TODO: show proper error component + console.error("[RoomsContainer] unable to fetch room availability") + return null + } + + if (!roomsAvailability) { + // HotelInfoCard has the logic for displaying when there are no rooms available + return null } return (