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

View File

@@ -76,7 +76,7 @@ export function ScheduleJobModalComponent({
}, },
]} ]}
> >
<DateTimePicker onBlur={handleDateBlur} /> <DateTimePicker onBlur={handleDateBlur} onlyFuture />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="scheduled_completion" name="scheduled_completion"
@@ -88,7 +88,7 @@ export function ScheduleJobModalComponent({
}, },
]} ]}
> >
<DateTimePicker /> <DateTimePicker onlyFuture />
</Form.Item> </Form.Item>
</LayoutFormRow> </LayoutFormRow>
<Card title={t("appointments.labels.smartscheduling")}> <Card title={t("appointments.labels.smartscheduling")}>