Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Refresh case list on status change #190

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/pages/ModelPages/Compute/ComputeObject/ComputeObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as Styled from '../Compute.styled';
import { CaseInfoTyoe } from '../ComputeVariogram/ComputeVariogram';

export const ComputeObject = () => {
const [refetchKey, setRefetchKey] = useState<number>(0);
const [showAlert, setAlert] = useState<string>();
const { modelId } = useParams<{ modelId: string }>();
const { instance, accounts } = useMsal();
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down