import { requestClient } from '#/api/request';

enum Api {
  base = '/examParticipant/participant',
  list = '/examParticipant/participant/list',
}

function getParticipantList(params: any) {
  return requestClient.get(Api.list, { params });
}

function getDetailParticipantList(params: any) {
  return requestClient.get(`${Api.base}/detail-list`, { params });
}

function startExam(id: number) {
  return requestClient.post(
    `${Api.base}/start/${id}`,
    {},
    {
      successMessageMode: 'message',
    },
  );
}

function endExam(id: number) {
  return requestClient.post(
    `${Api.base}/end/${id}`,
    {},
    {
      successMessageMode: 'message',
    },
  );
}

async function getParticipantById(id: number) {
  return requestClient.get(`${Api.base}/${id}`);
}

async function deleteParticipant(id: number) {
  return requestClient.delete(`${Api.base}/${id}`, {
    successMessageMode: 'message',
  });
}

export {
  deleteParticipant,
  endExam,
  getDetailParticipantList,
  getParticipantById,
  getParticipantList,
  startExam,
};
