import { request } from '@/utils/request'
import type { BaseResponse } from '../login/type'

/** 考试信息类型 */
export interface ExamItem {
  id: string
  examName: string
  examDate: string
  startTime: string
  endTime: string
  provinceName: string
  cityName: string
  address: string
  locationName: string
  estimatedAttendees: string
  examinersName?: string
  supervisorsName?: string
  status?: number
}

/** 获取可报名考试列表 */
export const getCanBookExamListAPI = () =>
  request.get<BaseResponse<ExamItem[]>>('/exam/getCanBookExamList')

/** 获取考试详情 */
export const getCanBookExamInfoAPI = (id: string) =>
  request.get<BaseResponse<ExamItem>>('/exam/getCanBookExamInfo', { params: { id } })

export const getAlreadyBookExamList = (id: string) =>
  request.get<BaseResponse<ExamItem>>('/exam/getAlreadyBookExamList', { params: { id } })

/** 报名接口 */
export const joinExamInfoAPI = (id: string) =>
  request.get<BaseResponse<any>>('/exam/joinExamInfo', { params: { id } })

/** 获取已报名考试列表 */
export const getAlreadyBookExamListAPI = () =>
  request.get<BaseResponse<ExamItem[]>>('/exam/getAlreadyBookExamList')
