Skip to content

Commit

Permalink
updated fork: redirect to old flow if ai sitegen is false
Browse files Browse the repository at this point in the history
  • Loading branch information
girish-lokapure committed Feb 27, 2024
1 parent a601bb0 commit 8353bc0
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/OnboardingSPA/steps/TheFork/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ import {
pluginDashboardPage,
} from '../../../constants';

import { DEFAULT_FLOW } from '../../data/flows/constants';
import { DEFAULT_FLOW, SITEGEN_FLOW } from '../../data/flows/constants';
import HeadingWithSubHeading from '../../components/HeadingWithSubHeading/SiteGen/index';
import StartOptions from '../../components/StartOptions';
import getContents from './contents';
import SitegenAiStateHandler from '../../components/StateHandlers/SitegenAi';
import { validateFlow } from '../../data/flows/utils';
import { resolveGetDataForFlow } from '../../data/flows';
import { useNavigate } from 'react-router-dom';

const TheFork = () => {
const { migrationUrl } = useSelect( ( select ) => {
const { migrationUrl, brandConfig, currentData } = useSelect( ( select ) => {

Check failure on line 23 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `·` with `⏎↹↹`

Check failure on line 23 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `·` with `⏎↹↹`
return {

Check failure on line 24 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`

Check failure on line 24 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`
migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(),

Check failure on line 25 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`

Check failure on line 25 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`
brandConfig: select( nfdOnboardingStore ).getNewfoldBrandConfig(),

Check failure on line 26 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `brandConfig:·` with `↹brandConfig:⏎↹↹↹↹↹`

Check failure on line 26 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `brandConfig:·` with `↹brandConfig:⏎↹↹↹↹↹`
currentData:

Check failure on line 27 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`

Check failure on line 27 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`
select( nfdOnboardingStore ).getCurrentOnboardingData(),

Check failure on line 28 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`

Check failure on line 28 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`
};

Check failure on line 29 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`

Check failure on line 29 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `↹`
} );

Check failure on line 30 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `}·` with `↹}⏎↹`

Check failure on line 30 in src/OnboardingSPA/steps/TheFork/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `}·` with `↹}⏎↹`

Expand All @@ -31,6 +37,12 @@ const TheFork = () => {
setIsHeaderNavigationEnabled,
setFooterActiveView,
setHideFooterNav,
updateAllSteps,
updateTopSteps,
updateRoutes,
updateDesignRoutes,
updateInitialize,
setCurrentOnboardingData,
} = useDispatch( nfdOnboardingStore );

useEffect( () => {
Expand All @@ -42,6 +54,26 @@ const TheFork = () => {
setDrawerActiveView( false );
setFooterActiveView( FOOTER_SITEGEN );
} );
const navigate = useNavigate();
useEffect( () => {
if ( false === validateFlow( brandConfig, SITEGEN_FLOW ) ) {
const currentFlow = window.nfdOnboarding.currentFlow;
const getData = resolveGetDataForFlow( DEFAULT_FLOW );
const data = getData();
updateAllSteps( data.steps );
updateTopSteps( data?.topSteps );
updateRoutes( data.routes );
updateDesignRoutes( data?.designRoutes );
if ( SITEGEN_FLOW !== currentFlow ) {
window.nfdOnboarding.oldFlow = currentFlow;
}
window.nfdOnboarding.currentFlow = DEFAULT_FLOW;
currentData.activeFlow = DEFAULT_FLOW;
setCurrentOnboardingData( currentData );
updateInitialize( true );
navigate( data.steps[ 1 ].path );
}
} );

const oldFlow = window.nfdOnboarding?.oldFlow
? window.nfdOnboarding.oldFlow
Expand Down

0 comments on commit 8353bc0

Please sign in to comment.