import { useMutation, useQuery } from "@tanstack/react-query";
import {
  getCompanies,
  getIdWithSlug,
  getIndustry,
  getCompanyDetail,
} from "../service/HomeService";

export const useGetSlugId = () => {
  return useMutation({
    mutationFn: (slug: string) => getIdWithSlug(slug),
  });
};

export const useGetIndustry = () => {
  return useQuery({
    queryKey: ["industry"],
    queryFn: () => getIndustry(),
  });
};

export const useGetCompanies = (industryId: string) => {
  return useQuery({
    queryKey: ["companies", industryId],
    queryFn: () => getCompanies(industryId),
  });
};

export const useGetCompanyDetail = (id: string) => {
  return useQuery({
    queryKey: ["company", id],
    queryFn: () => getCompanyDetail(id),
    enabled: !!id,
  });
};
