import { httpApp } from "@/plugins/axiosIndex";
import { pickBy } from "lodash-es";
import { object2QueryString } from "@/utils/utils";

export function searchInvigilators({
  examId = "",
  roomCode = "",
  userId = "",
  pageNumber = 1,
  pageSize = 10,
}) {
  const data = pickBy(
    { examId, roomCode, userId, pageNumber, pageSize },
    (v) => v !== ""
  );
  return httpApp.post(
    "/api/admin/invigilateUser/query?" + object2QueryString(data)
  );
}

export function saveInvigilator({ examId = "", roomCode = "", userIds = "" }) {
  const data = pickBy({ examId, roomCode, userIds }, (v) => v !== "");
  return httpApp.post("/api/admin/invigilateUser/save", data);
}
