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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user