IO-2485 Correct onlyFuture on typed values

This commit is contained in:
Allan Carr
2023-11-29 19:51:03 -08:00
parent 6570d38719
commit 806daebd3f
2 changed files with 23 additions and 13 deletions

View File

@@ -65,8 +65,17 @@ export function FormDatePicker({
});
}
if (_a.isValid() && onChange)
onChange(isDateOnly ? _a.format("YYYY-MM-DD") : _a);
if (_a.isValid() && onChange) {
if (onlyFuture) {
if (moment().subtract(1, "day").isBefore(_a)) {
onChange(isDateOnly ? _a.format("YYYY-MM-DD") : _a);
} else {
onChange(isDateOnly ? moment().format("YYYY-MM-DD") : moment());
}
} else {
onChange(isDateOnly ? _a.format("YYYY-MM-DD") : _a);
}
}
};
return (