import React, { Fragment } from 'react'; import { __ } from '@wordpress/i18n'; import CfIcon from '@WizardImages/cartflows-icon.svg'; import { getExitSetupWizard } from '@Utils/Helpers'; import { useStateValue } from '../utils/StateProvider'; import apiFetch from '@wordpress/api-fetch'; import { useLocation, useHistory } from 'react-router-dom'; import { Disclosure } from '@headlessui/react'; import { XMarkIcon } from '@heroicons/react/24/outline'; function Index() { const search = useLocation().search; const history = useHistory(); let step = new URLSearchParams( search ).get( 'step' ); step = step ? step : 'welcome'; const menus = [ { name: __( 'Welcome', 'cartflows' ), id: 'welcome', }, { name: __( 'Page Builder', 'cartflows' ), id: 'page-builder', }, { name: __( 'Required Plugins', 'cartflows' ), id: 'plugin-install', }, { name: __( 'Store Checkout', 'cartflows' ), id: 'store-checkout', }, { name: __( 'Subscribe', 'cartflows' ), id: 'optin', }, { name: __( 'Done', 'cartflows' ), id: 'ready', }, ]; const handleClick = ( e ) => { e.preventDefault(); const ajaxData = new window.FormData(); ajaxData.append( 'action', 'cartflows_onboarding_exit' ); ajaxData.append( 'security', cartflows_wizard.onboarding_exit_nonce ); ajaxData.append( 'current_step', step ); apiFetch( { url: ajaxurl, method: 'POST', body: ajaxData, } ).then( ( response ) => { if ( response.success ) { window.location.href = getExitSetupWizard(); } } ); }; const [ { selected_page_builder } ] = useStateValue(); if ( 'bricks-builder' === selected_page_builder ) { menus.splice( 3, 1 ); } const handleStepRedirection = function ( e ) { e.preventDefault(); if ( e.target.id ) { const stepToRedirect = e.target.id; history.push( { pathname: 'index.php', search: `?page=cartflow-setup&step=` + stepToRedirect, } ); } }; return ( <> { ( {} ) => ( <>
CartFlows CartFlows
{ menus.map( ( menu ) => { return ( { menu.name } ); } ) }
) }
); } export default Index;