From c80de0218d06c666587e0ab173b5cff1da7f1dc2 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Wed, 30 Oct 2024 10:38:54 +0100 Subject: [PATCH] feat: SW-633 Add validation in datepicker prefill from url --- components/BookingWidget/Client.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/BookingWidget/Client.tsx b/components/BookingWidget/Client.tsx index 46942ca44..479a43c1f 100644 --- a/components/BookingWidget/Client.tsx +++ b/components/BookingWidget/Client.tsx @@ -67,12 +67,14 @@ export default function BookingWidgetClient({ return undefined } + const reqFromDate = bookingWidgetSearchData?.fromDate?.toString() + const reqToDate = bookingWidgetSearchData?.toDate?.toString() + const isDateParamValid = - bookingWidgetSearchData?.fromDate && - bookingWidgetSearchData?.toDate && - dt(bookingWidgetSearchData?.toDate.toString()).isAfter( - dt(bookingWidgetSearchData?.fromDate.toString()) - ) + reqFromDate && + reqToDate && + dt(reqFromDate).isAfter(dt().subtract(1, "day")) && + dt(reqToDate).isAfter(dt(reqFromDate)) const selectedLocation = bookingWidgetSearchData ? getLocationObj(