From 362a796616f566fb20c513648d2a61a1bf085057 Mon Sep 17 00:00:00 2001 From: celineung Date: Mon, 9 Dec 2024 15:42:39 +0100 Subject: [PATCH] add missing values in hook deps --- .../forms/convention/ConventionForm.tsx | 4 ++-- .../beneficiary/BeneficiaryFormSection.tsx | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/front/src/app/components/forms/convention/ConventionForm.tsx b/front/src/app/components/forms/convention/ConventionForm.tsx index db7a7f8df2..6b41f1fe97 100644 --- a/front/src/app/components/forms/convention/ConventionForm.tsx +++ b/front/src/app/components/forms/convention/ConventionForm.tsx @@ -347,7 +347,7 @@ export const ConventionForm = ({ "partialConventionInUrl", ); dispatch(conventionSlice.actions.setCurrentStep(1)); - }, []); + }, [dispatch]); useEffect(() => { if (mode !== "create") { @@ -361,7 +361,7 @@ export const ConventionForm = ({ if (fetchedConvention) { reset(fetchedConvention); } - }, [fetchedConvention, methods.reset]); + }, [fetchedConvention, reset]); return ( diff --git a/front/src/app/components/forms/convention/sections/beneficiary/BeneficiaryFormSection.tsx b/front/src/app/components/forms/convention/sections/beneficiary/BeneficiaryFormSection.tsx index bc106fcd13..c37940fd91 100644 --- a/front/src/app/components/forms/convention/sections/beneficiary/BeneficiaryFormSection.tsx +++ b/front/src/app/components/forms/convention/sections/beneficiary/BeneficiaryFormSection.tsx @@ -76,18 +76,19 @@ export const BeneficiaryFormSection = ({ if (hasBeneficiaryRepresentativeData(initialBeneficiaryRepresentative)) { dispatch(conventionSlice.actions.isMinorChanged(true)); } - }, [initialBeneficiaryRepresentative]); + }, [dispatch, initialBeneficiaryRepresentative]); useEffect(() => { if (userFieldsAreFilled) { + const { firstName, lastName, email } = connectedUser; const valuesToUpdate = { - "signatories.beneficiary.firstName": connectedUser.firstName, - "signatories.beneficiary.lastName": connectedUser.lastName, - "signatories.beneficiary.email": connectedUser.email, + "signatories.beneficiary.firstName": firstName, + "signatories.beneficiary.lastName": lastName, + "signatories.beneficiary.email": email, }; keys(valuesToUpdate).forEach((key) => setValue(key, valuesToUpdate[key])); } - }, [userFieldsAreFilled]); + }, [userFieldsAreFilled, connectedUser, setValue]); useEffect(() => { const initialValues = values.signatories.beneficiaryCurrentEmployer; @@ -100,7 +101,11 @@ export const BeneficiaryFormSection = ({ } : undefined, ); - }, [hasCurrentEmployer]); + }, [ + hasCurrentEmployer, + setValue, + values.signatories.beneficiaryCurrentEmployer, + ]); const levelsOfEducationToSelectOption = levelsOfEducation.map( (level: string) => ({ label: level, value: level }), @@ -122,7 +127,7 @@ export const BeneficiaryFormSection = ({ setIsMinorAccordingToAge(newIsMinor); dispatch(conventionSlice.actions.isMinorChanged(newIsMinor)); }, - [dispatch, values.dateStart], + [dispatch, values.dateStart, setValue, getValues], ); useEffect(() => {