import { QueryClient } from '@tanstack/vue-query'

export const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: 30_000,
      retry: (failureCount, error: unknown) => {
        const status = typeof error === 'object' && error !== null && 'status' in error
          ? Number((error as { status: unknown }).status)
          : 0
        return ![400, 401, 403, 404, 409, 422].includes(status) && failureCount < 2
      },
      refetchOnWindowFocus: false
    },
    mutations: { retry: false }
  }
})
