import { useRef, useState, useEffect } from "@wordpress/element"; import { __ } from "@wordpress/i18n"; import { LeftArrow, RightArrow, TickIcon, RightArrowLong } from "../../icons/icons"; import WelcomePage from "./pages/welcome"; import BlocksSetup from "./pages/setup"; import classNames from "classnames"; import FinishPage from "./pages/finish"; import "../style.scss"; import { BlockPage, cardData } from "../pages/blocks"; import { WEBSITE_BUILDER_BLOCKS } from "../../controls/constants"; import { Toaster } from "react-hot-toast"; import Modules from "../pages/modules"; // const licenseStatus = sp_pcp_block_settings?.license_data?.status || false; const spPCPSiteType = sp_pcp_block_settings?.sp_ua_site_type; const SetupWizard = ({ blocksSettings, modulesOptions, blockShowHideHandler }) => { const footer = document.querySelector("#wpfooter"); if (footer) { footer.style.display = "none"; } const nextBtnRef = useRef(null); const [stepNumber, setStepNumber] = useState(0); const [websiteType, setWebsiteType] = useState(spPCPSiteType); const [isExiting, setIsExiting] = useState(false); const [errorMessage, setErrorMessage] = useState(""); const [direction, setDirection] = useState("left"); const [animationClass, setAnimationClass] = useState(""); const setupSteps = [ "Welcome", "Blocks", "Modules", "Finish", ]; const onAnimationEnd = () => { if (isExiting) { if (direction === "left") { setStepNumber((prev) => prev + 1); } else { setStepNumber((prev) => prev - 1); } setAnimationClass("is-entering"); setIsExiting(false); } }; const nextStep = () => { setDirection("left"); setIsExiting(true); setAnimationClass("is-exiting"); }; const handleNext = () => { if (stepNumber === 1 && websiteType === "") { setErrorMessage(true); return; } setErrorMessage(false); nextStep(); }; const handlePrev = () => { setDirection("right"); setIsExiting(true); setAnimationClass("is-exiting"); }; return (
{setupSteps?.map((step, index) => (
{index < stepNumber ? ( ) : ( "0" + (index + 1) )} {step} {index !== setupSteps.length - 1 && ( )}
))}
{setupSteps[stepNumber] === "Welcome" && ( )} {setupSteps[stepNumber] === "Blocks" && (

{__("Enable the Blocks You Need", "post-carousel")}

{__("Turn on the blocks that fit your workflow. You can update your selection anytime.", "post-carousel")}

)} {setupSteps[stepNumber] === "Modules" && (

{__("Enable the Modules You Need", "post-carousel")}

{__("Turn on the features that match your workflow. You can update your selection anytime.", "post-carousel")}

)} {setupSteps[stepNumber] === "Finish" && ( )}
{stepNumber !== 0 && stepNumber !== setupSteps.length - 1 && ( )} {stepNumber === 0 && ( {"Skip it"} )} {stepNumber !== setupSteps.length - 1 && ( )}
); }; export default SetupWizard;