import apiClient from '../client'
import type {
  PoolListResponse,
  PoolStatsResponse,
  PoolEntryResponse,
} from '../types'

export const poolApi = {
  addToPool: async (documentId: string, reason?: string): Promise<PoolEntryResponse> => {
    const { data } = await apiClient.post('/api/v1/admin/training/pool', {
      document_id: documentId,
      reason: reason ?? 'manual_addition',
    })
    return data
  },

  listEntries: async (params?: {
    verified_only?: boolean
    limit?: number
    offset?: number
  }): Promise<PoolListResponse> => {
    const { data } = await apiClient.get('/api/v1/admin/training/pool', { params })
    return data
  },

  getStats: async (): Promise<PoolStatsResponse> => {
    const { data } = await apiClient.get('/api/v1/admin/training/pool/stats')
    return data
  },

  verifyEntry: async (entryId: string): Promise<PoolEntryResponse> => {
    const { data } = await apiClient.post(`/api/v1/admin/training/pool/${entryId}/verify`)
    return data
  },

  removeEntry: async (entryId: string): Promise<{ message: string }> => {
    const { data } = await apiClient.delete(`/api/v1/admin/training/pool/${entryId}`)
    return data
  },
}
