import { useLocation, useNavigate } from 'react-router-dom'; import ONBOARDING_ROUTES_CONFIG from './onboardingRoutesConfig'; /** * This hook will return functions that will handle the navigation of the onboarding process. * It will be used to handle the back and continue buttons. */ export const useOnboardingNavigation = () => { const navigate = useNavigate(); const urlParams = new URLSearchParams( useLocation().search ); const currentRoute = urlParams.get( 'step' ) || 'welcome'; const BASE_PATH = '?page=woo-cart-abandonment-recovery&path=onboarding&step='; const getNextRoute = ( currentPath ) => { const currentIndex = ONBOARDING_ROUTES_CONFIG.findIndex( ( route ) => route.url === currentPath ); return ONBOARDING_ROUTES_CONFIG[ currentIndex + 1 ].url; }; const getPreviousRoute = ( currentPath ) => { const currentIndex = ONBOARDING_ROUTES_CONFIG.findIndex( ( route ) => route.url === currentPath ); return ONBOARDING_ROUTES_CONFIG[ currentIndex - 1 ].url; }; const navigateToNextRoute = () => { const nextRoute = getNextRoute( currentRoute ); navigate( { search: BASE_PATH + nextRoute, } ); }; const navigateToPreviousRoute = () => { const previousRoute = getPreviousRoute( currentRoute ); navigate( { search: BASE_PATH + previousRoute, } ); }; const getCurrentStepNumber = () => { const currentIndex = ONBOARDING_ROUTES_CONFIG.findIndex( ( route ) => route.url === currentRoute ); return currentIndex + 1; }; const getCurrentStep = () => { return ONBOARDING_ROUTES_CONFIG.find( ( route ) => route.url === currentRoute ); }; const navigateToStep = ( stepNumber ) => { // Convert step number to index (stepNumber is 1-based, array is 0-based) const targetIndex = stepNumber - 1; // Check if step number is valid if ( targetIndex < 0 || targetIndex >= ONBOARDING_ROUTES_CONFIG.length ) { return; } const targetRoute = ONBOARDING_ROUTES_CONFIG[ targetIndex ]; // Check if we can navigate to this step by checking requirements for ( let i = 0; i <= targetIndex; i++ ) { const route = ONBOARDING_ROUTES_CONFIG[ i ]; // Skip routes without requirements if ( ! route?.requires?.stateKeys || route?.requires?.stateKeys?.length === 0 ) { continue; } } // If all requirements are met, navigate to the target step navigate( { search: BASE_PATH + targetRoute.url, } ); }; return { getNextRoute, getPreviousRoute, navigateToNextRoute, navigateToPreviousRoute, getCurrentStepNumber, getCurrentStep, navigateToStep, }; }; [data-vc-shortcode="vc_line_chart"], [data-vc-shortcode="vc_round_chart"] { // vc_line-chart custom dependency .vc_chart-edit-form-custom-color { .vc_shortcode-param[data-vc-shortcode-param-name="values_custom_color"] { display: block; } .vc_shortcode-param[data-vc-shortcode-param-name="values_color"] { display: none; } } .vc_shortcode-param[data-vc-shortcode-param-name="values_custom_color"] { display: none; } }!function(t){"use strict";var e={theme:"fip-grey",source:!1,emptyIcon:!0,emptyIconValue:"",iconsPerPage:20,hasSearch:!0,searchSource:!1,useAttribute:!1,attributeName:"data-icon",convertToHex:!0,allCategoryText:"From all categories",unCategorizedText:"Uncategorized"};function i(i,s){this.element=t(i),this.settings=t.extend({},e,s),this.settings.emptyIcon&&this.settings.iconsPerPage--,this.iconPicker=t("
",{"class":"icons-selector",style:"position: relative",html:'
'}),this.iconContainer=this.iconPicker.find(".fip-icons-container"),this.searchIcon=this.iconPicker.find(".selector-search i"),this.iconsSearched=[],this.isSearch=!1,this.totalPage=1,this.currentPage=1,this.currentIcon=!1,this.iconsCount=0,this.open=!1,this.searchValues=[],this.availableCategoriesSearch=[],this.triggerEvent=null,this.backupSource=[],this.backupSearch=[],this.isCategorized=!1,this.selectCategory=this.iconPicker.find(".icon-category-select"),this.selectedCategory=!1,this.availableCategories=[],this.unCategorizedKey=null,this.init()}i.prototype={init:function(){this.iconPicker.addClass(this.settings.theme),this.iconPicker.css({left:-9999}).appendTo("body");var e=this.iconPicker.outerHeight(),i=this.iconPicker.outerWidth();if(this.iconPicker.css({left:""}),this.element.before(this.iconPicker),this.element.css({visibility:"hidden",top:0,position:"relative",zIndex:"-1",left:"-"+i+"px",display:"inline-block",height:e+"px",width:i+"px",padding:"0",margin:"0 -"+i+"px 0 0",border:"0 none",verticalAlign:"top"}),!this.element.is("select")){var s=function(){for(var t=3,e=document.createElement("div"),i=e.all||[];e.innerHTML="\x3c!--[if gt IE "+ ++t+"]>
4?t:!t}(),n=document.createElement("div");this.triggerEvent=9!==s&&"oninput"in n?["input","keyup"]:["keyup"]}!this.settings.source&&this.element.is("select")?(this.settings.source=[],this.settings.searchSource=[],this.element.find("optgroup").length?(this.isCategorized=!0,this.element.find("optgroup").each(t.proxy((function(e,i){var s=this.availableCategories.length,n=t("