import React from 'react'; import { Schedule } from '@/api/server/schedules/getServerSchedules'; import Modal, { RequiredModalProps } from '@/components/elements/Modal'; import Field from '@/components/elements/Field'; import { connect } from 'react-redux'; import { Form, FormikProps, withFormik } from 'formik'; import { Actions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; import Switch from '@/components/elements/Switch'; import { boolean, object, string } from 'yup'; type OwnProps = { schedule: Schedule } & RequiredModalProps; interface ReduxProps { addError: ApplicationStore['flashes']['addError']; } type ComponentProps = OwnProps & ReduxProps; interface Values { name: string; dayOfWeek: string; dayOfMonth: string; hour: string; minute: string; enabled: boolean; } const EditScheduleModal = ({ values, schedule, ...props }: ComponentProps & FormikProps) => { return (

The schedule system supports the use of Cronjob syntax when defining when tasks should begin running. Use the fields above to specify when these tasks should begin running.

); }; export default connect( null, // @ts-ignore (dispatch: Actions) => ({ addError: dispatch.flashes.addError, }), )( withFormik({ handleSubmit: (values, { props }) => { }, mapPropsToValues: ({ schedule }) => ({ name: schedule.name, dayOfWeek: schedule.cron.dayOfWeek, dayOfMonth: schedule.cron.dayOfMonth, hour: schedule.cron.hour, minute: schedule.cron.minute, enabled: schedule.isActive, }), validationSchema: object().shape({ name: string().required(), enabled: boolean().required(), }), })(EditScheduleModal), );