import { useState, useEffect } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { useTasksStore } from '@assist/state/tasks'; const launchSteps = { 'site-information': { step: __('Site Industry', 'extendify-local'), title: __("Let's Start Building Your Website", 'extendify-local'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with our Site Launcher.', 'extendify-local', ), buttonText: __('Add Website Details', 'extendify-local'), }, goals: { step: __('Goals', 'extendify-local'), title: __('Continue Building Your Website', 'extendify-local'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with our Site Launcher.', 'extendify-local', ), buttonText: __('Select Site Goals', 'extendify-local'), }, 'site-structure': { step: __('Site Structure', 'extendify-local'), title: __('Continue Building Your Website', 'extendify-local'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with our Site Launcher.', 'extendify-local', ), buttonText: __('Pick Your Site Structure', 'extendify-local'), }, layout: { step: __('Design', 'extendify-local'), title: __('Continue Building Your Website', 'extendify-local'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with our Site Launcher.', 'extendify-local', ), buttonText: __('Select Site Design', 'extendify-local'), }, 'page-select': { step: __('Pages', 'extendify-local'), title: __('Continue Building Your Website', 'extendify-local'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with our Site Launcher.', 'extendify-local', ), buttonText: __('Select Site Pages', 'extendify-local'), }, }; const getCurrentLaunchStep = () => { const pageData = JSON.parse( localStorage.getItem(`extendify-pages-${window.extSharedData.siteId}`), ) || { state: {} }; const currentPageSlug = pageData?.state?.currentPageSlug; // If their last step doesn't exist in our options, just use step 1 if (!Object.keys(launchSteps).includes(currentPageSlug)) { return 'site-information'; } return currentPageSlug; }; export const LaunchCard = ({ task }) => { const [currentStep, setCurrentStep] = useState(); const { dismissTask } = useTasksStore(); useEffect(() => { if (currentStep) return; setCurrentStep(getCurrentLaunchStep()); }, [currentStep]); return (
{task?.htmlBefore()}

{launchSteps[currentStep]?.title}

{launchSteps[currentStep]?.description}

{launchSteps[currentStep]?.buttonText}
); };