import apiClient from './client'

export interface PendingIdentification {
  id: number
  face_id: number
  photo_id?: number | null
  user_id: number
  user_name?: string | null
  user_email: string
  first_name: string
  last_name: string
  middle_name?: string | null
  maiden_name?: string | null
  date_of_birth?: string | null
  status: string
  created_at: string
  updated_at: string
}

export interface PendingIdentificationsListResponse {
  items: PendingIdentification[]
  total: number
}

export interface ApproveDenyDecision {
  id: number
  decision: 'approve' | 'deny'
}

export interface ApproveDenyRequest {
  decisions: ApproveDenyDecision[]
}

export interface ApproveDenyResponse {
  approved: number
  denied: number
  errors: string[]
}

export const pendingIdentificationsApi = {
  list: async (includeDenied: boolean = false): Promise<PendingIdentificationsListResponse> => {
    const res = await apiClient.get<PendingIdentificationsListResponse>(
      '/api/v1/pending-identifications',
      { params: { include_denied: includeDenied } }
    )
    return res.data
  },
  approveDeny: async (request: ApproveDenyRequest): Promise<ApproveDenyResponse> => {
    const res = await apiClient.post<ApproveDenyResponse>(
      '/api/v1/pending-identifications/approve-deny',
      request
    )
    return res.data
  },
}

export default pendingIdentificationsApi

