import { useApiInterceptor } from "./useApiInterceptor";

export const useRecommendedJobs = (
  pageInfo: string | null = "?",
  sortAndFilterOptions: string | null = "",
  titleSearchKeyword: string | null = "",
  locationSearchKeyword: string | null = "",
  jobTypeKeyword: string | null = "",
  workModeKeyword: string | null = "",
  datePostedRange: string | null = ""
) => {
  return new Promise(async (resolve, reject) => {
    try {
      const response = await useApiInterceptor().get(
        `/job-posts${pageInfo}&sort=${sortAndFilterOptions}&search=${titleSearchKeyword}&location=${locationSearchKeyword}&employment-type=${jobTypeKeyword}&work-mode=${workModeKeyword}&date-posted=${datePostedRange}`
      );
      resolve({ resp: response.data, status: response.status });
    } catch (error) {
      console.error("Error fetching API (Recommended Jobs):", error);
      reject(error);
    }
  });
};
