import { useQuery } from '@tanstack/react-query'
import { listUsers } from '../api/listUsers'
import type { UsuariosQuery } from '../types'

export const usersListQueryKey = (query: UsuariosQuery) => ['users', 'list', query] as const

export function useUsersList(query: UsuariosQuery) {
  return useQuery({
    queryKey: usersListQueryKey(query),
    queryFn: () => listUsers(query),
    staleTime: 15_000,
  })
}
