Skip to content

Commit e1d071c

Browse files
committed
fix: Invalidate queries after editing cluster properly
1 parent 98a64a8 commit e1d071c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/features/clusters/upsert/ClusterForm.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { toKebabCase } from '@/lib/string/to-kebab-case';
1919
import { queryKeys } from '@/react-query/constants';
2020
import { zodResolver } from '@hookform/resolvers/zod';
2121
import { useQueryClient } from '@tanstack/react-query';
22-
import { useNavigate } from '@tanstack/react-router';
22+
import { useNavigate, useRouter } from '@tanstack/react-router';
2323
import { useCallback, useEffect, useMemo, useState } from 'react';
2424
import { useForm } from 'react-hook-form';
2525
import { toast } from 'sonner';
@@ -55,6 +55,7 @@ export function ClusterForm({
5555
startOffOnBilling,
5656
}: ClusterFormProps) {
5757
const navigate = useNavigate();
58+
const router = useRouter();
5859

5960
const queryClient = useQueryClient();
6061
const { mutate: submitNewClusterData, isPending: isCreatePending } = useCreateNewClusterMutation();
@@ -266,6 +267,11 @@ export function ClusterForm({
266267
toastId: string | number;
267268
}) => {
268269
void queryClient.invalidateQueries({ queryKey: [queryKeys.organization], refetchType: 'active' });
270+
if (!creating) {
271+
void queryClient.invalidateQueries({ queryKey: [queryKeys.cluster, clusterId], refetchType: 'active' });
272+
}
273+
274+
void router.invalidate();
269275
void navigate({ to: creating ? '../' : '../../' });
270276
toast.success(creating ? 'Cluster Created' : 'Cluster Updated', {
271277
id: toastId,
@@ -276,7 +282,7 @@ export function ClusterForm({
276282
: 'The updates are being provisioned now.',
277283
duration: 5_000,
278284
});
279-
}, [navigate, queryClient]);
285+
}, [clusterId, navigate, queryClient, router]);
280286

281287
const submitCreateCluster = useCallback(async () => {
282288
const formData = form.getValues();

0 commit comments

Comments
 (0)