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

export function useDeleteChargeableCharConfig() {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: (id: number) => deleteChargeableCharConfig(id),
    onSuccess: (_data, id) => {
      queryClient.invalidateQueries({ queryKey: ['chargeableChars', 'list'] })
      queryClient.removeQueries({ queryKey: ['chargeableChars', id] })
    },
  })
}
