Skip to content

Commit

Permalink
Refetch on actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang committed Jan 4, 2025
1 parent c8a5f4e commit 14e03db
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pages/admin/nodeversions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { CustomPagination } from '@/components/common/CustomPagination'
import withAdmin from '@/components/common/HOC/authAdmin'
import { NodeVersionStatusToReadable } from 'src/mapper/nodeversion'
import { useQueryClient } from '@tanstack/react-query'

function NodeVersionList({}) {
const router = useRouter()
Expand All @@ -36,6 +37,7 @@ function NodeVersionList({}) {
const versions = getAllNodeVersionsQuery.data?.versions || []

const updateNodeVersionMutation = useAdminUpdateNodeVersion()
const queryClient = useQueryClient()

React.useEffect(() => {
if (getAllNodeVersionsQuery.isError) {
Expand Down Expand Up @@ -64,6 +66,9 @@ function NodeVersionList({}) {
{
onSuccess: () => {
toast.success('Node version approved')
queryClient.invalidateQueries({
queryKey: ['/versions'],
})
},
onError: () => {
toast.error('Error approving node version')
Expand All @@ -85,6 +90,12 @@ function NodeVersionList({}) {
{
onSuccess: () => {
toast.success('Node version rejected')
queryClient.invalidateQueries({
queryKey: ['/versions'],
})
queryClient.refetchQueries({
queryKey: ['/versions'],
})
},
onError: () => {
toast.error('Error rejecting node version')
Expand Down Expand Up @@ -216,7 +227,7 @@ function NodeVersionList({}) {
color="failure"
onClick={() =>
onReject(
nodeVersion as string,
nodeVersion.node_id as string,
nodeVersion.version as string
)
}
Expand Down

0 comments on commit 14e03db

Please sign in to comment.