Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated fork: redirect to old flow if ai sitegen is false #490

Merged
merged 11 commits into from
Feb 28, 2024
5 changes: 4 additions & 1 deletion src/OnboardingSPA/components/StartOptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => {
if ( ! validateFlow( brandConfig, newFlow ) ) {
return false;
}
window.nfdOnboarding.currentBrand = brandConfig;
Copy link
Member

@arunshenoy99 arunshenoy99 Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's safe to store brandConfig in the window object. Let's try FlowStateHandler like we discussed yesterday.

const currentFlow = window.nfdOnboarding.currentFlow;
const getData = resolveGetDataForFlow( newFlow );
const data = getData();
Expand All @@ -46,8 +47,10 @@ const StartOptions = ( { questionnaire, oldFlow, options } ) => {
setCurrentOnboardingData( currentData );
if ( SITEGEN_FLOW !== newFlow ) {
updateInitialize( true );
navigate( data.steps[ 0 ].path );
} else {
navigate( data.steps[ 1 ].path );
}
navigate( data.steps[ 1 ].path );
};
const selectFlow = ( flow ) => {
switch ( flow ) {
Expand Down
14 changes: 12 additions & 2 deletions src/OnboardingSPA/data/flows/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ import { indexPage } from '../../pages/IndexPage/page';
import { brush } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { stepTheFork } from '../../steps/TheFork/step';
import { validateFlow } from '../../data/flows/utils';
import { SITEGEN_FLOW } from '../../data/flows/constants';

export const pages = [ indexPage, errorPage ];

export const initialChapters = [ demographic, design, layoutContent, features ];

export const getSteps = ( chapters = initialChapters ) => {
let steps = [];
steps.push( stepTheFork );
if (
validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW )
) {
steps.push( stepTheFork );
}
steps.push( stepWelcome );
chapters.forEach( ( chapter ) => {
steps = steps.concat( [
Expand All @@ -34,7 +40,11 @@ export const getSteps = ( chapters = initialChapters ) => {

export const getRoutes = ( chapters = initialChapters ) => {
let routes = [ ...pages ];
routes.push( stepTheFork );
if (
validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW )
) {
routes.push( stepTheFork );
}
routes.push( stepWelcome );
chapters.forEach( ( chapter ) => {
routes = routes.concat( [
Expand Down
15 changes: 13 additions & 2 deletions src/OnboardingSPA/data/flows/ecommerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { filter } from 'lodash';
import { store } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { stepTheFork } from '../../steps/TheFork/step';
import { validateFlow } from '../../data/flows/utils';
import { SITEGEN_FLOW } from '../../data/flows/constants';

export const pages = [ indexPage, errorPage ];

Expand All @@ -32,7 +34,12 @@ export const initialChapters = [

export const getSteps = ( chapters = initialChapters ) => {
let steps = [];
steps.push( stepTheFork );
if (
validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW )
) {
steps.push( stepTheFork );
}

steps.push( stepWelcome );
chapters.forEach( ( chapter ) => {
steps = steps.concat( [
Expand All @@ -49,7 +56,11 @@ export const getSteps = ( chapters = initialChapters ) => {

export const getRoutes = ( chapters = initialChapters ) => {
let routes = [ ...pages ];
routes.push( stepTheFork );
if (
validateFlow( window.nfdOnboarding.currentBrand.config, SITEGEN_FLOW )
) {
routes.push( stepTheFork );
}
routes.push( stepWelcome );
chapters.forEach( ( chapter ) => {
routes = routes.concat( [
Expand Down
Loading