import request from './request'

export interface ProjectItem {
  id: number
  name: string
  template_id: number
  status: string
  description?: string
  target_source_ids?: string
  planned_start?: string
  planned_end?: string
  created_at: string
  stats?: {
    total: number
    auto: number
    manual: number
    reviewed: number
  }
}

export function getProjects(params?: { page?: number; page_size?: number; keyword?: string }) {
  return request.get('/projects', { params })
}

export function getProject(id: number) {
  return request.get(`/projects/${id}`)
}

export function createProject(data: { name: string; template_id: number; target_source_ids?: string; description?: string }) {
  return request.post('/projects', null, { params: data })
}

export function deleteProject(id: number) {
  return request.delete(`/projects/${id}`)
}

export function autoClassifyProject(id: number, background: boolean = true) {
  return request.post(`/projects/${id}/auto-classify`, undefined, { params: { background } })
}

export function getAutoClassifyStatus(id: number) {
  return request.get(`/projects/${id}/auto-classify-status`)
}
