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 228407e6a..c75096635 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 ( <>