import React from 'react'; import PropTypes from 'prop-types'; import { Button, Form } from '@patternfly/react-core'; import { translate as __ } from 'foremanReact/common/I18n'; import { ScheduleType } from './ScheduleType'; import { RepeatOn } from './RepeatOn'; import { QueryType } from './QueryType'; import { StartEndDates } from './StartEndDates'; import { WIZARD_TITLES } from '../../JobWizardConstants'; import { WizardTitle } from '../form/WizardTitle'; const Schedule = ({ scheduleValue, setScheduleValue }) => { const { repeatType, repeatAmount, starts, ends, isNeverEnds } = scheduleValue; return ( <>
{ if (!newValue) { // if schedule type is execute now setScheduleValue(current => ({ ...current, starts: '', })); } setScheduleValue(current => ({ ...current, isFuture: newValue, })); }} /> { setScheduleValue(current => ({ ...current, repeatType: newValue, })); }} repeatAmount={repeatAmount} setRepeatAmount={newValue => { setScheduleValue(current => ({ ...current, repeatAmount: newValue, })); }} /> { if (!scheduleValue.isFuture) { setScheduleValue(current => ({ ...current, isFuture: true, })); } setScheduleValue(current => ({ ...current, starts: newValue, })); }} ends={ends} setEnds={newValue => { setScheduleValue(current => ({ ...current, ends: newValue, })); }} isNeverEnds={isNeverEnds} setIsNeverEnds={newValue => { setScheduleValue(current => ({ ...current, isNeverEnds: newValue, })); }} /> ); }; Schedule.propTypes = { scheduleValue: PropTypes.shape({ repeatType: PropTypes.string.isRequired, repeatAmount: PropTypes.string, starts: PropTypes.string, ends: PropTypes.string, isFuture: PropTypes.bool, isNeverEnds: PropTypes.bool, }).isRequired, setScheduleValue: PropTypes.func.isRequired, }; export default Schedule;