diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx index f1ff11e7f..d0a436f21 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/NoAvailabilityAlert.tsx @@ -18,7 +18,7 @@ export default async function NoAvailabilityAlert({ const intl = await getIntl() const lang = await getLang() - if (bookingCode && isBookingCodeRateNotAvailable) { + if (bookingCode && isBookingCodeRateNotAvailable && hotelsLength > 0) { const bookingCodeText = intl.formatMessage( { defaultMessage: diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts b/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts index d418738d3..138af84d2 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts @@ -1,3 +1,4 @@ +import { dt } from "@scandic-hotels/common/dt" import { AvailabilityEnum } from "@scandic-hotels/trpc/enums/selectHotel" import { generateChildrenString } from "@scandic-hotels/trpc/routers/hotels/helpers" @@ -182,6 +183,14 @@ export async function getHotels({ redemption, }: GetHotelsInput) { let availableHotelsResponse: SettledResult = [] + + // Return empty array (forced No availability) when search dates are invalid + if ( + dt(fromDate).isBefore(dt(), "day") || + dt(toDate).isSameOrBefore(fromDate, "day") + ) { + return [] + } if (isAlternativeFor) { availableHotelsResponse = await Promise.allSettled( rooms.map(async (room) => { diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx index cea02e683..1acf7e87e 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/index.tsx @@ -14,8 +14,6 @@ import { RoomsContainerSkeleton } from "./RoomsContainerSkeleton" import styles from "./index.module.css" -import type { AppRouter } from "@scandic-hotels/trpc/routers/appRouter" - import type { RoomsContainerProps } from "@/types/components/hotelReservation/selectRate/roomsContainer" export function RoomsContainer({}: RoomsContainerProps) { @@ -23,7 +21,7 @@ export function RoomsContainer({}: RoomsContainerProps) { const { availability: { error, isFetching, isError }, - input: { hasError: hasInputError }, + input: { hasError: hasInputError, errorCode }, } = useSelectRateContext() if (isFetching) { @@ -31,7 +29,7 @@ export function RoomsContainer({}: RoomsContainerProps) { } if (isError || hasInputError) { - const errorMessage = getErrorMessage(error, intl) + const errorMessage = getErrorMessage(error ?? errorCode, intl) return (