import type { AxiosResponse } from 'axios'
import request from '@/utils/request'

import type { PageInfo, Result, RuntimeTask } from '@cacp/ui'
import type { GovernmentInfo, GovernmentQueryInfo, UserTaskQueryInfo } from '@/types/government'

const contextPath = '/government'

//获取列表
export async function getPageList(query: GovernmentQueryInfo): Promise<Result<PageInfo<GovernmentInfo>>> {
  const res: AxiosResponse<Result<PageInfo<GovernmentInfo>>> = await request.post(`${contextPath}/get-page-list`, query)
  return res.data
}

export async function get(formId: string): Promise<Result<GovernmentInfo>> {
  const res: AxiosResponse<Result<GovernmentInfo>> = await request.get(`${contextPath}/get`, {
    params: { formId: formId }
  })
  return res.data
}

export async function getUserTaskListByPage(query: UserTaskQueryInfo): Promise<Result<PageInfo<RuntimeTask>>> {
  const res: AxiosResponse<Result<PageInfo<RuntimeTask>>> = await request.post(`${contextPath}/get-user-task-list-by-page`, query)
  return res.data
}
