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

// 复制
export function useCopyDataset() {
  const queryClient = useQueryClient()

  return useMutation({
    mutationFn: (data: { id: string; name: string; force: string }) => copyDataset(data),
    onSuccess: () => {
      message.success('复制成功')
      queryClient.invalidateQueries({ queryKey: ['data'] })
      queryClient.invalidateQueries({ queryKey: ['dataFiled'] })
    },
  })
}
