import { useApiInterceptor } from "./useApiInterceptor";

export const useGetCompanies = (
  pageInfo: string | null = "?",
  sortAndFilterOptions: string | null = "",
  titleSearchKeyword: string | null = "",
  locationSearchKeyword: string | null = "",
) => {
  return new Promise(async (resolve, reject) => {
    try {
      const response = await useApiInterceptor().get(
        `/account/companies${pageInfo}&sort=${sortAndFilterOptions}&search=${titleSearchKeyword}&location=${locationSearchKeyword}`
      );
      resolve({ resp: response.data, status: response.status });
    } catch (error) {
      console.error("Error fetching API (Companies):", error);
      reject(error);
    }
  });
};
