import { useState, useEffect } from "react";

export const useWebflowInfo = () => {
  const [webflowSiteLoading, setWebflowSiteLoading] = useState<boolean>(true);
  const [webflowId, setWebflowId] = useState<string>("");
  const [webflowError, setWebflowError] = useState<string>("");

  useEffect(() => {
    webflow
      .getSiteInfo()
      .then(({ siteId }) => {
        setWebflowId(siteId);
        setWebflowSiteLoading(false);
      })
      .catch((error) => setWebflowError(error));
  }, []);

  return {
    webflowSiteLoading,
    webflowId,
    webflowError,
  };
};
