Skip to content

Commit

Permalink
[Surveillance] Lors de l'édition de la zone de surveillance le bouton…
Browse files Browse the repository at this point in the history
… "zone identique a zone de mission" est décoché et inactif (#579)

- Resolve #571 
- Resolve #570
  • Loading branch information
claire2212 committed Jun 7, 2023
2 parents 473dd56 + a383344 commit 03c9fea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { FormikCheckbox, FormikDatePicker, FormikTextarea } from '@mtes-mct/monitor-ui'
import { useField } from 'formik'
import { useMemo } from 'react'
import { Form, IconButton } from 'rsuite'
import styled from 'styled-components'

import { InteractionListener } from '../../../../domain/entities/map/constants'
import { ActionTypeEnum, type EnvAction } from '../../../../domain/entities/missions'
import { useAppSelector } from '../../../../hooks/useAppSelector'
import { useNewWindow } from '../../../../ui/NewWindow'
import { ReactComponent as DeleteSVG } from '../../../../uiMonitor/icons/Delete.svg'
import { ReactComponent as SurveillanceIconSVG } from '../../../../uiMonitor/icons/Observation.svg'
Expand All @@ -25,6 +27,9 @@ export function SurveillanceForm({ currentActionIndex, readOnly, remove, setCurr
const hasCustomZone = geomField.value && geomField.value.coordinates.length > 0
const surveillances = actionsFields.value.filter(action => action.actionType === ActionTypeEnum.SURVEILLANCE)

const { listener } = useAppSelector(state => state.draw)
const isEditingZone = useMemo(() => listener === InteractionListener.SURVEILLANCE_ZONE, [listener])

const duration = dateDifferenceInHours(
envActionField.value.actionStartDateTimeUtc,
envActionField.value.actionEndDateTimeUtc
Expand Down Expand Up @@ -107,7 +112,7 @@ export function SurveillanceForm({ currentActionIndex, readOnly, remove, setCurr
readOnly={readOnly}
/>
<StyledFormikCheckbox
disabled={hasCustomZone}
disabled={hasCustomZone || isEditingZone}
inline
label="Zone de surveillance équivalente à la zone de mission"
name={`envActions[${currentActionIndex}].coverMissionZone`}
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/features/missions/MultiPointPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ const Field = styled.div`
align-items: flex-start;
display: flex;
flex-direction: column;
> button {
max-width: 416px;
}
`
const Center = styled.div`
cursor: pointer;
Expand All @@ -170,7 +167,7 @@ const Row = styled.div`
}
align-items: center;
display: flex;
width: 100%;
margin-bottom: 4px;
> button {
Expand All @@ -185,5 +182,4 @@ const ZoneWrapper = styled.div`
font-size: 13px;
justify-content: space-between;
padding: 5px 0.75rem 4px;
width: 416px;
`
8 changes: 6 additions & 2 deletions frontend/src/features/missions/MultiZonePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export function MultiZonePicker({
const { value } = field

const { listener } = useAppSelector(state => state.draw)
const isEditingZone = useMemo(() => listener === InteractionListener.MISSION_ZONE, [listener])
const isEditingZone = useMemo(
() => listener === InteractionListener.MISSION_ZONE || listener === InteractionListener.SURVEILLANCE_ZONE,
[listener]
)

const polygons = useMemo(() => {
if (!value) {
Expand Down Expand Up @@ -143,6 +146,7 @@ const Field = styled.div`
align-items: flex-start;
display: flex;
flex-direction: column;
width: 100%;
`
const Center = styled.a`
cursor: pointer;
Expand All @@ -160,6 +164,7 @@ const Row = styled.div`
align-items: center;
display: flex;
margin: 0.5rem 0 0;
width: 100%;
> button {
margin: 0 0 0 0.5rem;
Expand All @@ -173,7 +178,6 @@ const ZoneWrapper = styled.div<{ isLight?: boolean }>`
font-size: 13px;
justify-content: space-between;
padding: 5px 0.75rem 4px;
width: 416px;
`

const ErrorMessage = styled.div`
Expand Down

0 comments on commit 03c9fea

Please sign in to comment.