Skip to content

Commit

Permalink
[Reporting] Display reportings on map when user draw a point or a zone
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Jan 28, 2025
1 parent 9a1ca8d commit 2f437a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/features/Mission/components/Layers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Geometry } from 'ol/geom'

export function MissionsLayer({ map, mapClickEvent }: BaseMapChildrenProps) {
const dispatch = useAppDispatch()
const { displayMissionsLayer } = useAppSelector(state => state.global)
const displayMissionsLayer = useAppSelector(state => state.global.displayMissionsLayer)
const { missions } = useGetFilteredMissionsQuery()

// mission attached to active reporting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { reportingActions } from '@features/Reportings/slice'
import { useAppDispatch } from '@hooks/useAppDispatch'
import { useAppSelector } from '@hooks/useAppSelector'
import { Layers } from 'domain/entities/layers/constants'
import { InteractionListener } from 'domain/entities/map/constants'
import { removeOverlayStroke } from 'domain/shared_slices/Global'
import { convertToFeature } from 'domain/types/map'
import { reduce } from 'lodash'
Expand Down Expand Up @@ -37,7 +38,7 @@ export function ReportingsLayer({ map, mapClickEvent }: BaseMapChildrenProps) {
state => state.attachReportingToMission.isReportingAttachmentInProgress
)

const missionListener = useAppSelector(state => state.draw.listener)
const drawListener = useAppSelector(state => state.draw.listener)
// Attached reportings to active mission
const activeMission = useAppSelector(state => getActiveMission(state.missionForms))
const attachedReportingsToActiveMission = activeMission?.missionForm.attachedReportings
Expand Down Expand Up @@ -84,7 +85,11 @@ export function ReportingsLayer({ map, mapClickEvent }: BaseMapChildrenProps) {
const reportingsPointOrZone = useMemo(() => {
// if user edits a mission with attached reportings and draw a zone or a point on map
// we want to display only the attached reportings
if (missionListener) {
if (
drawListener === InteractionListener.MISSION_ZONE ||
drawListener === InteractionListener.SURVEILLANCE_ZONE ||
drawListener === InteractionListener.CONTROL_POINT
) {
return [...attachedReportingsToActiveMissionFeature]
}

Expand All @@ -100,7 +105,7 @@ export function ReportingsLayer({ map, mapClickEvent }: BaseMapChildrenProps) {
attachedReportingsToActiveMission,
attachedReportingsToActiveMissionFeature,
reportingsFromApiFeatures,
missionListener
drawListener
])

const hasMapListener = isMissionAttachmentInProgress || isReportingAttachmentInProgress
Expand Down

0 comments on commit 2f437a7

Please sign in to comment.