import apiClient from './client'

export interface ReportedPhotoResponse {
  id: number
  photo_id: number
  user_id: number
  user_name: string | null
  user_email: string | null
  status: string
  reported_at: string
  reviewed_at: string | null
  reviewed_by: number | null
  review_notes: string | null
  report_comment: string | null
  photo_path: string | null
  photo_filename: string | null
  photo_media_type: string | null
}

export interface ReportedPhotosListResponse {
  items: ReportedPhotoResponse[]
  total: number
}

export interface ReviewDecision {
  id: number
  decision: 'keep' | 'remove'
  review_notes?: string | null
}

export interface ReviewRequest {
  decisions: ReviewDecision[]
}

export interface ReviewResponse {
  kept: number
  removed: number
  errors: string[]
}

export interface ReportedCleanupResponse {
  deleted_records: number
  errors: string[]
  warnings?: string[]
}

export const reportedPhotosApi = {
  listReportedPhotos: async (statusFilter?: string): Promise<ReportedPhotosListResponse> => {
    const { data } = await apiClient.get<ReportedPhotosListResponse>(
      '/api/v1/reported-photos',
      {
        params: statusFilter ? { status_filter: statusFilter } : undefined,
      }
    )
    return data
  },

  reviewReportedPhotos: async (request: ReviewRequest): Promise<ReviewResponse> => {
    const { data } = await apiClient.post<ReviewResponse>(
      '/api/v1/reported-photos/review',
      request
    )
    return data
  },

  cleanupReportedPhotos: async (): Promise<ReportedCleanupResponse> => {
    const { data } = await apiClient.post<ReportedCleanupResponse>(
      '/api/v1/reported-photos/cleanup',
      {},
    )
    return data
  },
}

