import { deleteRequest, getRequest, postRequest } from ".";
import apiEndpoints from "./apiEndpoints";

export const getFilteredCandidates = (payload) => {
  let technologiesQuery = "";
  for (let i = 0; i < payload.technologies.length; i++) {
    technologiesQuery += `technologies=${payload.technologies[i]}&`;
  }
  return getRequest(
    apiEndpoints.candidates.filteredCandidates +
      "?currentPage=" +
      payload.currentPage +
      "&pageSize=" +
      payload.pageSize +
      "&minExperience=" +
      payload.minExperience +
      "&maxExperience=" +
      payload.maxExperience +
      "&employmentType=" +
      payload.employmentType +
      "&minDateOfApplication=" +
      payload.minDateOfApplication +
      "&maxDateOfApplication=" +
      payload.maxDateOfApplication +
      "&" +
      technologiesQuery
  );
};
export const getCandidate = (id) =>
  getRequest(apiEndpoints.candidates.filteredCandidates + "/" + id);
export const createComment = (data) =>
  postRequest(apiEndpoints.comments.addComment, data);
export const getAllAdsCandidates = () =>
  getRequest(apiEndpoints.candidates.allAdsCandidates);
export const deleteCandidate = (id) =>
  deleteRequest(apiEndpoints.candidates.allCandidates + "?id=" + id);
