import { useMutation, useQueryClient } from '@tanstack/react-query'
import { deactivateRole } from '../api/deactivateRole'
import { rolesQueryKey } from './useRoles'

export function useDeactivateRole() {
  const qc = useQueryClient()
  return useMutation({
    mutationFn: (codigo: string) => deactivateRole(codigo),
    onSuccess: () => {
      void qc.invalidateQueries({ queryKey: rolesQueryKey })
    },
  })
}
