diff --git a/src/screens/actions/form/ActionForm.tsx b/src/screens/actions/form/ActionForm.tsx index 9ce4aee4d..e1e96b2d9 100644 --- a/src/screens/actions/form/ActionForm.tsx +++ b/src/screens/actions/form/ActionForm.tsx @@ -77,7 +77,7 @@ export default function ActionForm({ onCancel, onClose, uuid, scope }: Props) { if (formState.errors.post_address) { setManualAddress(true) } - }, [formState.errors.post_address]) + }, [formState]) if ((!data || !isFullAction(data)) && uuid) return null diff --git a/src/screens/profil/account/form/AbstractProfilForm.tsx b/src/screens/profil/account/form/AbstractProfilForm.tsx index a96686599..fd6420c95 100644 --- a/src/screens/profil/account/form/AbstractProfilForm.tsx +++ b/src/screens/profil/account/form/AbstractProfilForm.tsx @@ -28,12 +28,13 @@ const AbstractForm = , TF extends FieldValues>( defaultValues: props.defaultValues, mode: 'all', }) + const { isDirty, isValid } = formState React.useEffect(() => { if (props.onErrors) { props.onErrors(formState.errors) } - }, [formState.errors]) + }, [formState]) const { mutateAsync, isPending } = useMutationUpdateProfil({ userUuid: props.uuid }) @@ -60,10 +61,10 @@ const AbstractForm = , TF extends FieldValues>( {props.children({ control, formState })} - reset()}> + reset()}> Annuler - + Enregister diff --git a/src/screens/profil/elu/components/DeclaForm.tsx b/src/screens/profil/elu/components/DeclaForm.tsx index 3dc62234d..55aa02ab3 100644 --- a/src/screens/profil/elu/components/DeclaForm.tsx +++ b/src/screens/profil/elu/components/DeclaForm.tsx @@ -32,6 +32,7 @@ export default function (props: Props) { }) const { mutateAsync, isPending } = usePostElectDeclaration() + const { isDirty, isValid } = formState const onSubmit = handleSubmit((data) => { mutateAsync(data) @@ -89,10 +90,10 @@ export default function (props: Props) { }} /> - reset()}> + reset()}> Annuler - + Enregister diff --git a/src/screens/profil/elu/components/DeclaMandateEluCard.tsx b/src/screens/profil/elu/components/DeclaMandateEluCard.tsx index 3361903b3..5e33f481a 100644 --- a/src/screens/profil/elu/components/DeclaMandateEluCard.tsx +++ b/src/screens/profil/elu/components/DeclaMandateEluCard.tsx @@ -79,6 +79,7 @@ export default function (props: { profil: RestElectedProfileResponse }) { mandates: props.profil?.mandates || [], }, }) + const { isDirty } = formState const { mutateAsync, isPending } = useMutationUpdateProfil({ userUuid: props.profil.uuid }) const onSubmit = handleSubmit((x) => mutateAsync(x).then(() => { @@ -103,10 +104,10 @@ export default function (props: { profil: RestElectedProfileResponse }) { }} /> - reset()}> + reset()}> Annuler - + Enregistrer diff --git a/src/screens/profil/elu/components/IbanForm.tsx b/src/screens/profil/elu/components/IbanForm.tsx index e8ff2a893..96e1db7e6 100644 --- a/src/screens/profil/elu/components/IbanForm.tsx +++ b/src/screens/profil/elu/components/IbanForm.tsx @@ -76,6 +76,8 @@ export default function (props: Props) { mode: 'all', }) + const { isDirty, isValid } = formState + const { mutateAsync, isPending } = usePostElectPayment() const onSubmit = handleSubmit((data) => { @@ -178,10 +180,10 @@ export default function (props: Props) { }} /> - reset()}> + reset()}> Annuler - + Enregister