From acd36cec326f31046ac3c1bad2c9e6b4c61ff5b6 Mon Sep 17 00:00:00 2001 From: Nipun Arora Date: Tue, 3 Dec 2024 00:24:14 +0530 Subject: [PATCH] Fixed toast issue + fixed invalidation of assumption and formula --- .../microplan/src/components/HypothesisWrapper.js | 4 +++- .../src/pages/employee/SetupMicroplan.js | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/HypothesisWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/HypothesisWrapper.js index c91b23045c..1079181e80 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/HypothesisWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/HypothesisWrapper.js @@ -69,7 +69,9 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => { { enabled: microplanId ? true : false, cacheTime: 0, - // queryKey: currentKey, + staleTime:0, + refetchOnMount: true, + queryKey:state?.allAssumptions ? state?.allAssumptions.length : "hypothesis_plan" } ); diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SetupMicroplan.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SetupMicroplan.js index 036f1c582c..a1b93dfa3b 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SetupMicroplan.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SetupMicroplan.js @@ -159,9 +159,17 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => { setCurrentStep(Number(filteredConfig?.[0]?.form?.[0]?.stepCount - 1)); // setting the toast to null when moving to next step successfully // if any issue comes related to Toast, update here - setShowToast(null); + // setShowToast(null); + // this null was causing toast to immediatealy go to null since filteredConfig gets affected }, [currentKey, filteredConfig]); + useEffect(() => { + // setting the toast to null when moving to next step successfully + // if any issue comes related to Toast, update here + setShowToast(null) + }, [currentKey]) + + useEffect(() => { setIsSubmitting(false); Digit.Utils.microplanv1.updateUrlParams({ key: currentKey }); @@ -179,7 +187,8 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => { onSuccess: (data) => { // Check if there is a redirectTo property in the response if (data?.redirectTo) { - history.push(data?.redirectTo, data?.state); // Navigate to the specified route + history.push(data?.redirectTo, data?.state); + return; // Navigate to the specified route } //invalidation of files session @@ -218,8 +227,10 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => { Digit.SessionStorage.del("HYPOTHESIS_DATA"); Digit.SessionStorage.del("FORMULA_DATA"); + setCurrentKey((prev) => prev + 1); setCurrentStep((prev) => prev + 1); + //since we are invalidating we need to update this global state dispatch({