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

export function useCreateRubro() {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: (payload: CreateRubroRequest) => createRubro(payload),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['rubros'] })
    },
  })
}
