import { useMutation } from '@tanstack/react-query'
import { processData } from './api'
import type { ProcessDataParams } from './types'
import { useProcessProgressQuery } from '@/hooks/useQuery'

// 处理数据
export function useProcessData() {
  const { data, start, remove } = useProcessProgressQuery({ function_name: 'split' })

  const query = useMutation({
    mutationFn: (data: ProcessDataParams) => {
      return processData(data)
    },
    onSuccess: () => {
      start()
    },
  })

  return { ...query, progress: data.progress, message: data.message, remove }
}
