@@ -24,12 +24,13 @@ import { excludeFalsy } from '@/lib/arrays/excludeFalsy';
2424import { authStore } from '@/lib/authStore' ;
2525import { getOperationsUrlForCluster } from '@/lib/urls/getOperationsUrlForCluster' ;
2626import { useQueryClient } from '@tanstack/react-query' ;
27- import { Link } from '@tanstack/react-router' ;
27+ import { Link , useRouter } from '@tanstack/react-router' ;
2828import { CopyIcon , Ellipsis } from 'lucide-react' ;
2929import { useCallback , useMemo , useState } from 'react' ;
3030import { toast } from 'sonner' ;
3131
3232export function ClusterCard ( { cluster } : { cluster : Cluster ; } ) {
33+ const router = useRouter ( ) ;
3334 const queryClient = useQueryClient ( ) ;
3435 const operationsUrl = useMemo ( ( ) => getOperationsUrlForCluster ( cluster ) , [ cluster ] ) ;
3536 const instanceClient = useInstanceClient ( operationsUrl ) ;
@@ -69,7 +70,12 @@ export function ClusterCard({ cluster }: { cluster: Cluster; }) {
6970 const handleTerminatedCluster = useCallback ( ( ) => {
7071 const organizationId = cluster . organizationId ;
7172 terminateCluster ( cluster . id , {
72- onSuccess : ( ) => {
73+ onSuccess : async ( ) => {
74+ await queryClient . invalidateQueries ( {
75+ queryKey : [ organizationId ] ,
76+ refetchType : 'active' ,
77+ } ) ;
78+ await router . invalidate ( ) ;
7379 toast . success ( 'Success' , {
7480 description : isSelfManaged
7581 ? `Cluster successfully removed.`
@@ -80,10 +86,6 @@ export function ClusterCard({ cluster }: { cluster: Cluster; }) {
8086 onClick : ( ) => toast . dismiss ( ) ,
8187 } ,
8288 } ) ;
83- void queryClient . invalidateQueries ( {
84- queryKey : [ organizationId ] ,
85- refetchType : 'active' ,
86- } ) ;
8789 setIsTerminateClusterModalOpen ( false ) ;
8890 } ,
8991 onError : ( ) => {
@@ -100,7 +102,7 @@ export function ClusterCard({ cluster }: { cluster: Cluster; }) {
100102 setIsTerminateClusterModalOpen ( false ) ;
101103 } ,
102104 } ) ;
103- } , [ cluster . organizationId , cluster . id , cluster . name , terminateCluster , isSelfManaged , queryClient ] ) ;
105+ } , [ router , cluster . organizationId , cluster . id , cluster . name , terminateCluster , isSelfManaged , queryClient ] ) ;
104106
105107 const [ onCopyFQDNClick , onCopyAPIClick ] = useCopyToClipboard (
106108 `${ cluster . fqdn } ` ,
0 commit comments