Add support for creating a new task
This commit is contained in:
parent
ef38a51d6d
commit
b0f47ea01a
3 changed files with 45 additions and 3 deletions
|
@ -10,6 +10,7 @@ import { httpErrorToHuman } from '@/api/http';
|
|||
import Field from '@/components/elements/Field';
|
||||
import FormikFieldWrapper from '@/components/elements/FormikFieldWrapper';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import { number, object, string } from 'yup';
|
||||
|
||||
interface Props {
|
||||
scheduleId: number;
|
||||
|
@ -52,6 +53,14 @@ export default ({ task, scheduleId, onDismissed }: Props) => {
|
|||
payload: task?.payload || '',
|
||||
timeOffset: task?.timeOffset.toString() || '0',
|
||||
}}
|
||||
validationSchema={object().shape({
|
||||
action: string().required().oneOf(['command', 'power']),
|
||||
payload: string().required('A task payload must be provided.'),
|
||||
timeOffset: number().typeError('The time offset must be a valid number between 0 and 900.')
|
||||
.required('A time offset value must be provided.')
|
||||
.min(0, 'The time offset must be at least 0 seconds.')
|
||||
.max(900, 'The time offset must be less than 900 seconds.'),
|
||||
})}
|
||||
>
|
||||
{({ values, isSubmitting }) => (
|
||||
<Modal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue