import apiClient from './client'
import type {
  FlowProposalSummary,
  FlowProposalDetail,
  FlowProposalStats,
  ReviewProposalRequest,
} from '@/types/flow-proposal'

export const flowProposalsApi = {
  async list(params?: {
    status?: string
    type?: string
    domain?: string
    sort_by?: string
    skip?: number
    limit?: number
  }): Promise<FlowProposalSummary[]> {
    const response = await apiClient.get<FlowProposalSummary[]>('/flow-proposals', { params })
    return response.data
  },

  async getStats(): Promise<FlowProposalStats> {
    const response = await apiClient.get<FlowProposalStats>('/flow-proposals/stats')
    return response.data
  },

  async get(id: string): Promise<FlowProposalDetail> {
    const response = await apiClient.get<FlowProposalDetail>(`/flow-proposals/${id}`)
    return response.data
  },

  async review(id: string, data: ReviewProposalRequest): Promise<FlowProposalDetail> {
    const response = await apiClient.post<FlowProposalDetail>(
      `/flow-proposals/${id}/review`,
      data
    )
    return response.data
  },
}

export default flowProposalsApi
