import { useApiInterceptor } from "./useApiInterceptor";

export const useGetCandidates = (
  pageInfo: string | null = '?',
  sortAndFilterOptions: string | null = '',
  titleSearchKeyword: string | null = '',
  locationSearchKeyword: string | null = '',
  hasPsychometricResults?: string[],
  gender?: string,
  isVerified?: string
) => {
  return new Promise(async (resolve, reject) => {
    try {
      const response = await useApiInterceptor().post(`/candidates${pageInfo}&sort=${sortAndFilterOptions}&name=${titleSearchKeyword}&location=${locationSearchKeyword}`, {
        hasPsychometricResults,
        gender,
        isVerified
      });
      resolve({ resp: response.data, status: response.status });
    } catch (error) {
      console.error('Error fetching API (Candidates):', error);
      reject(error);
    }
  })
}
