import { useMutation, useQueryClient } from '@tanstack/react-query'
import { moveRubro } from '../api/moveRubro'
import type { MoveRubroRequest } from '../types'

export function useMoveRubro() {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: ({ id, data }: { id: number; data: MoveRubroRequest }) => moveRubro(id, data),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['rubros'] })
    },
  })
}
