Skip to content

Commit

Permalink
Close draw modal on mission form exit
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Mar 20, 2024
1 parent ae1b06e commit 26839bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { autoSaveMissionAction } from '@features/Mission/useCases/autoSaveMissio
import { deleteMission } from '@features/Mission/useCases/deleteMission'
import { deleteMissionAction } from '@features/Mission/useCases/deleteMissionAction'
import { saveMissionAndMissionActionsByDiff } from '@features/Mission/useCases/saveMissionAndMissionActionsByDiff'
import { cleanMissionForm } from '@features/SideWindow/useCases/cleanMissionForm'
import { openSideWindowPath } from '@features/SideWindow/useCases/openSideWindowPath'
import { useMainAppDispatch } from '@hooks/useMainAppDispatch'
import { useMainAppSelector } from '@hooks/useMainAppSelector'
Expand Down Expand Up @@ -167,8 +168,7 @@ export function MissionForm() {
const goToMissionList = useCallback(async () => {
const canExit = await dispatch(openSideWindowPath({ menu: SideWindowMenuKey.MISSION_LIST }))
if (canExit) {
dispatch(missionFormActions.resetMissionForm())
dispatch(missionFormActions.unsetSelectedMissionGeoJSON())
dispatch(cleanMissionForm())
}
}, [dispatch])

Expand Down
10 changes: 10 additions & 0 deletions frontend/src/features/SideWindow/useCases/cleanMissionForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { closeDraw } from '@features/Draw/useCases/closeDraw'
import { missionFormActions } from '@features/Mission/components/MissionForm/slice'

import type { MainAppThunk } from '@store'

export const cleanMissionForm = (): MainAppThunk => dispatch => {
dispatch(missionFormActions.resetMissionForm())
dispatch(missionFormActions.unsetSelectedMissionGeoJSON())
dispatch(closeDraw())
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cleanMissionForm } from '@features/SideWindow/useCases/cleanMissionForm'
import { UseCaseStore } from '@store/UseCaseStore'
import { assertNotNullish } from '@utils/assertNotNullish'

Expand All @@ -15,4 +16,5 @@ export const confirmSideWindowDraftCancellationAndProceed = (): MainAppThunk =>
}
dispatch(sideWindowActions.closeDraftCancellationConfirmationDialog())
dispatch(sideWindowActions.openOrFocusAndGoTo(sideWindow.nextPath))
dispatch(cleanMissionForm())
}

0 comments on commit 26839bc

Please sign in to comment.