import { getToken } from "@/config/func";
import { useQuery } from "@tanstack/react-query";
import * as api from "../service/BusinessService";

export const useGetBusinessCatalog = (slug: string) => {
  return useQuery({
    queryKey: ["businessCatalog", slug],
    queryFn: () => api.getBusinessCatalog(slug),
    enabled: !!slug,
  });
};

export const useGetBusinessBySlug = (slug: string) => {
  return useQuery({
    queryKey: ["business", slug],
    queryFn: () => api.getBusinessBySlug(slug),
    enabled: !!slug,
  });
};

export const useGetBusiness = () => {
  return useQuery({
    queryKey: ["mybusiness"],
    queryFn: api.getBusiness,
    enabled: !!getToken(),
  });
};
