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

// 导入
export function useImportDataset() {
  const queryClient = useQueryClient()

  return useMutation({
    mutationFn: (data: { name: string; file: string }) => importDataset(data),
    onSuccess: () => {
      message.success('导入成功')
      queryClient.invalidateQueries({ queryKey: ['data'] })
      queryClient.invalidateQueries({ queryKey: ['dataFiled'] })
    },
  })
}
