From 9429065ede02ec80346668e6fd23925100d66c0f Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Wed, 22 Jan 2025 17:20:09 +0100 Subject: [PATCH] [Mission] Delete setFieldValue in useEffect - Awareness component --- .../ActionForm/SurveillanceForm/Awareness.tsx | 15 +++++++++++---- .../Mission/components/MissionForm/constants.ts | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/features/Mission/components/MissionForm/ActionForm/SurveillanceForm/Awareness.tsx b/frontend/src/features/Mission/components/MissionForm/ActionForm/SurveillanceForm/Awareness.tsx index 228407e6a8..c750966354 100644 --- a/frontend/src/features/Mission/components/MissionForm/ActionForm/SurveillanceForm/Awareness.tsx +++ b/frontend/src/features/Mission/components/MissionForm/ActionForm/SurveillanceForm/Awareness.tsx @@ -1,4 +1,4 @@ -import { FormikCheckbox, FormikNumberInput, FormikSelect, Label } from '@mtes-mct/monitor-ui' +import { Checkbox, FormikNumberInput, FormikSelect, Label } from '@mtes-mct/monitor-ui' import { useField, useFormikContext } from 'formik' import { useEffect } from 'react' import styled from 'styled-components' @@ -22,21 +22,28 @@ export function Awareness({ awarenessOptions, formPath }: AwarenessProps) { if (controlPlans.value.length === 1 && isRisingAwareness) { setFieldValue(`${formPath}.awareness.themeId`, controlPlans.value[0]?.themeId) } - if (!isRisingAwareness) { + }, [controlPlans.value, formPath, isRisingAwareness, setFieldValue]) + + const updateIsRisingAwareness = (isChecked: boolean | undefined) => { + if (isChecked) { + setFieldValue(`${formPath}.awareness`, { isRisingAwareness: true }) + } else { setFieldValue(`${formPath}.awareness`, undefined) } - }, [controlPlans.value, formPath, isRisingAwareness, setFieldValue]) + } return ( <>
-
diff --git a/frontend/src/features/Mission/components/MissionForm/constants.ts b/frontend/src/features/Mission/components/MissionForm/constants.ts index 974b8a6e46..c5abb6734f 100644 --- a/frontend/src/features/Mission/components/MissionForm/constants.ts +++ b/frontend/src/features/Mission/components/MissionForm/constants.ts @@ -11,7 +11,8 @@ export const MISSION_EVENT_UNSYNCHRONIZED_PROPERTIES = [ // `envActions` is included but `reportingIds` is missing 'envActions', 'fishActions', - 'hasRapportNavActions' + 'hasRapportNavActions', + 'observationsByUnit' ] export const MISSION_EVENT_UNSYNCHRONIZED_PROPERTIES_IN_FORM = [