From f28381025b1dd9b13957e37e24cf28be089f11da Mon Sep 17 00:00:00 2001 From: mheggelund Date: Thu, 4 Jan 2024 15:14:04 +0100 Subject: [PATCH] fix: Refresh case list on status change --- .../Compute/ComputeObject/ComputeObject.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx b/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx index 8c1f9044..c8681760 100644 --- a/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx +++ b/src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx @@ -19,6 +19,7 @@ import * as Styled from '../Compute.styled'; import { CaseInfoTyoe } from '../ComputeVariogram/ComputeVariogram'; export const ComputeObject = () => { + const [refetchKey, setRefetchKey] = useState(0); const [showAlert, setAlert] = useState(); const { modelId } = useParams<{ modelId: string }>(); const { instance, accounts } = useMsal(); @@ -31,8 +32,12 @@ export const ComputeObject = () => { setAlert('New object case saved'); }; + const uppdateCaseList = () => { + setRefetchKey(refetchKey + 1); + }; + const { data } = useQuery({ - queryKey: ['model-cases', modelId], + queryKey: ['model-cases', modelId, refetchKey], queryFn: () => AnalogueModelComputeCasesService.getApiAnalogueModelsComputeCases( modelId as string, @@ -79,7 +84,10 @@ export const ComputeObject = () => { const res = await computeObject.mutateAsync(requestBody); - if (res.success) setAlert('Started computing case'); + if (res.success) { + uppdateCaseList(); + setAlert('Started computing case'); + } }; // Returnerer Cases fra DB