From a924590fe508ebeec97f3c2fbf74c7dfabe77fad Mon Sep 17 00:00:00 2001 From: Clara Ni Date: Thu, 2 Jan 2025 18:00:12 +0100 Subject: [PATCH] front: reset stdcm state when hitting "new query" button Signed-off-by: Clara Ni --- front/src/applications/stdcm/hooks/useStdcm.ts | 9 +++++++++ front/src/applications/stdcm/views/StdcmView.tsx | 2 ++ 2 files changed, 11 insertions(+) diff --git a/front/src/applications/stdcm/hooks/useStdcm.ts b/front/src/applications/stdcm/hooks/useStdcm.ts index 251a21cc73c..dc4124fb519 100644 --- a/front/src/applications/stdcm/hooks/useStdcm.ts +++ b/front/src/applications/stdcm/hooks/useStdcm.ts @@ -68,6 +68,14 @@ const useStdcm = ({ const { speedLimitByTag } = useStoreDataForSpeedLimitByTagSelector({ isStdcm: true }); + const resetStdcmState = () => { + setStdcmTrainResult(undefined); + setStdcmTrainConflicts(undefined); + setStdcmResponse(undefined); + setPathProperties(undefined); + setCurrentStdcmRequestStatus(STDCM_REQUEST_STATUS.idle); + } + const triggerShowFailureNotification = (error: Error) => { if (showFailureNotification) { dispatch(setFailure(error)); @@ -163,6 +171,7 @@ const useStdcm = ({ stdcmResults, launchStdcmRequest, cancelStdcmRequest, + resetStdcmState, pathProperties, setPathProperties, isPending, diff --git a/front/src/applications/stdcm/views/StdcmView.tsx b/front/src/applications/stdcm/views/StdcmView.tsx index 9464b883cc2..793a63a4434 100644 --- a/front/src/applications/stdcm/views/StdcmView.tsx +++ b/front/src/applications/stdcm/views/StdcmView.tsx @@ -33,6 +33,7 @@ const StdcmView = () => { const { launchStdcmRequest, cancelStdcmRequest, + resetStdcmState, isPending, isRejected, isCanceled, @@ -63,6 +64,7 @@ const StdcmView = () => { const handleStartNewQuery = () => { setSimulationsList([]); + resetStdcmState(); setSelectedSimulationIndex(-1); setRetainedSimulationIndex(-1); dispatch(resetStdcmConfig());