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

export function useCreateChargeableCharConfig() {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: (payload: CreateChargeableCharConfigRequest) =>
      createChargeableCharConfig(payload),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['chargeableChars', 'list'] })
    },
  })
}
