IO-1017 Schedule modal only future dates.

This commit is contained in:
Patrick Fic
2021-05-06 18:32:37 -07:00
parent 3543bfac16
commit 58a314f72d
2 changed files with 12 additions and 3 deletions

View File

@@ -6,7 +6,10 @@ import { TimePicker } from "antd";
import moment from "moment";
//To be used as a form element only.
const DateTimePicker = ({ value, onChange, onBlur, id, ...restProps }, ref) => {
const DateTimePicker = (
{ value, onChange, onBlur, id, onlyFuture, ...restProps },
ref
) => {
// const handleChange = (newDate) => {
// if (value !== newDate && onChange) {
// onChange(newDate);
@@ -17,6 +20,9 @@ const DateTimePicker = ({ value, onChange, onBlur, id, ...restProps }, ref) => {
<div id={id}>
<FormDatePicker
{...restProps}
{...(onlyFuture && {
disabledDate: (d) => moment().subtract(1, "day").isAfter(d),
})}
value={value}
onBlur={onBlur}
onChange={onChange}
@@ -25,6 +31,9 @@ const DateTimePicker = ({ value, onChange, onBlur, id, ...restProps }, ref) => {
<TimePicker
{...restProps}
value={value ? moment(value) : null}
{...(onlyFuture && {
disabledDate: (d) => moment().isAfter(d),
})}
onChange={onChange}
showSecond={false}
minuteStep={15}