Fix task edit modal not filling the payload correctly
This commit is contained in:
parent
c58348735d
commit
a966613890
|
@ -32,11 +32,16 @@ interface Values {
|
||||||
}
|
}
|
||||||
|
|
||||||
const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {
|
const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {
|
||||||
const { values: { action }, setFieldValue, setFieldTouched, isSubmitting } = useFormikContext<Values>();
|
const { values: { action }, initialValues, setFieldValue, setFieldTouched, isSubmitting } = useFormikContext<Values>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFieldValue('payload', action === 'power' ? 'start' : '');
|
if (action !== initialValues.action) {
|
||||||
setFieldTouched('payload', false);
|
setFieldValue('payload', action === 'power' ? 'start' : '');
|
||||||
|
setFieldTouched('payload', false);
|
||||||
|
} else {
|
||||||
|
setFieldValue('payload', initialValues.payload);
|
||||||
|
setFieldTouched('payload', false);
|
||||||
|
}
|
||||||
}, [ action ]);
|
}, [ action ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue