import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { Form } from '@patternfly/react-core';
import { ScheduleType } from './ScheduleType';
import { RepeatOn } from './RepeatOn';
import { QueryType } from './QueryType';
import { StartEndDates } from './StartEndDates';
import { WIZARD_TITLES, repeatTypes } from '../../JobWizardConstants';
import { PurposeField } from './PurposeField';
import { WizardTitle } from '../form/WizardTitle';
const Schedule = ({ scheduleValue, setScheduleValue, setValid }) => {
const {
repeatType,
repeatAmount,
repeatData,
startsAt,
startsBefore,
ends,
isNeverEnds,
isFuture,
isTypeStatic,
purpose,
} = scheduleValue;
const [validEnd, setValidEnd] = useState(true);
const [repeatValid, setRepeatValid] = useState(true);
useEffect(() => {
if (!validEnd || !repeatValid) {
setValid(false);
} else if (isFuture && (startsAt.length || startsBefore.length)) {
setValid(true);
} else if (!isFuture) {
setValid(true);
} else {
setValid(false);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [startsAt, startsBefore, isFuture, validEnd, repeatValid]);
return (
<>