Calendar: Fix incorrect time when scheduling (#1379)

This commit is contained in:
Alexander Zinchuk 2021-08-12 15:36:24 +03:00
parent a03f4c7189
commit b1f91c921b

View File

@ -73,6 +73,14 @@ const CalendarModal: FC<OwnProps> = ({
}
}, [isOpen, defaultSelectedDate, prevIsOpen]);
useEffect(() => {
if (isFutureMode && selectedDate.getTime() < defaultSelectedDate.getTime()) {
setSelectedDate(defaultSelectedDate);
setSelectedHours(formatInputTime(defaultSelectedDate.getHours()));
setSelectedMinutes(formatInputTime(defaultSelectedDate.getMinutes()));
}
}, [defaultSelectedDate, isFutureMode, selectedDate]);
const shouldDisableNextMonth = (isPastMode && currentYear >= now.getFullYear() && currentMonth >= now.getMonth())
|| (maxDate && currentYear >= maxDate.getFullYear() && currentMonth >= maxDate.getMonth());
const shouldDisablePrevMonth = isFutureMode && currentYear <= now.getFullYear() && currentMonth <= now.getMonth();