Merged in fix/SW-3254-error-fromdate_cannot_be_ (pull request #2676)

Fix/SW-3254 error fromdate cannot be

* fix(SW-3254): Implemented date valdaton on select-hotel page

* fix(SW-3254): Updated the browser URL to show proper booking dates

* fix(SW-3254): Fixed select-rate when invalid dates searched

* fix(SW-3254): Forced no availability for past dates

* fix(SW-3254) Optimised code

* fix(SW-3254): Optimised code


Approved-by: Linus Flood
This commit is contained in:
Hrishikesh Vaipurkar
2025-08-21 09:48:31 +00:00
parent d2bbbc0a47
commit 3f19886171
5 changed files with 21 additions and 22 deletions

View File

@@ -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:

View File

@@ -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) => {