Skip to content

Commit

Permalink
updated checks
Browse files Browse the repository at this point in the history
  • Loading branch information
girish-lokapure committed Feb 1, 2024
1 parent 40606a3 commit ab7fc3e
Show file tree
Hide file tree
Showing 15 changed files with 240 additions and 159 deletions.
2 changes: 0 additions & 2 deletions src/OnboardingSPA/chapters/sitegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { __ } from '@wordpress/i18n';
import { stepSiteGenWelcome } from '../steps/SiteGen/Welcome/step';
import { stepSiteGenSiteDetails } from '../steps/SiteGen/SiteDetails/step';
import { stepSiteGenSiteLogo } from '../steps/SiteGen/SiteLogo/step';
import { stepSiteGenSiteError} from '../steps/SiteGen/SiteError/step';
import { stepSiteGenSocialMedia } from '../steps/SiteGen/SocialMedia/step';
import { stepSiteGenExperience } from '../steps/SiteGen/Experience/step';
import { stepSiteGenBuilding } from '../steps/SiteGen/Building/step';
Expand All @@ -15,7 +14,6 @@ const steps = [
stepSiteGenWelcome,
stepSiteGenSiteDetails,
stepSiteGenSocialMedia,
stepSiteGenSiteError,
stepSiteGenSiteLogo,
stepSiteGenExperience,
stepSiteGenBuilding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const SiteGen = () => {
}
);

const { setCurrentOnboardingData } = useDispatch( nfdOnboardingStore );
const { setCurrentOnboardingData, updateSiteGenErrorStatus } = useDispatch( nfdOnboardingStore );

Check failure on line 56 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `·` with `⏎↹↹`

async function syncStoreToDB() {
if ( currentData ) {
Expand All @@ -69,6 +69,7 @@ const SiteGen = () => {
retryCount = 1
) {
return new Promise( () =>

Check failure on line 71 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Delete `⏎`

generateSiteGenMeta( siteInfo, identifier, skipCache )
.then( ( data ) => {
if ( data.body !== null ) {
Expand All @@ -82,10 +83,14 @@ const SiteGen = () => {
retryCount + 1
);
}
if ( retryCount === MAX_RETRIES_SITE_GEN ) {
updateSiteGenErrorStatus( true );
}
} )
.catch( ( err ) => {
/* eslint-disable no-console */
console.log( err );
updateSiteGenErrorStatus( true );
} )
);
}
Expand Down
File renamed without changes.
149 changes: 149 additions & 0 deletions src/OnboardingSPA/components/SiteGenError/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { useViewportMatch } from '@wordpress/compose';
import { useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import getContents from './contents';
import { Button, Fill } from '@wordpress/components';
import { store as nfdOnboardingStore } from '../../store';
import CommonLayout from '../Layouts/Common';
import OrbAnimation from '../OrbAnimation';
import { SITEGEN_FLOW, DEFAULT_FLOW } from '../../data/flows/constants';
import { validateFlow } from '../../data/flows/utils';
import { resolveGetDataForFlow } from '../../data/flows';
import { useNavigate } from 'react-router-dom';
import {
FOOTER_SITEGEN,
FOOTER_END,
HEADER_SITEGEN,
pluginDashboardPage,
} from '../../../constants';

const SiteGenSiteError = () => {
const navigate = useNavigate();
const {
setIsHeaderEnabled,
setSidebarActiveView,
setHeaderActiveView,
setDrawerActiveView,
setHideFooterNav,
setIsHeaderNavigationEnabled,
updateAllSteps,
updateTopSteps,
updateRoutes,
updateDesignRoutes,
updateInitialize,
setCurrentOnboardingData,
updateSiteGenErrorStatus,
} = useDispatch( nfdOnboardingStore );

useEffect( () => {
setHideFooterNav( true );
setIsHeaderEnabled( true );
setSidebarActiveView( false );
setHeaderActiveView( HEADER_SITEGEN );
setIsHeaderNavigationEnabled( true );
setDrawerActiveView( false );
} );

const { brandConfig, currentData } = useSelect( ( select ) => {
return {
brandConfig: select( nfdOnboardingStore ).getNewfoldBrandConfig(),
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
};
} );
const isLargeViewport = useViewportMatch( 'small' );

const content = getContents();
const oldFlow = window.nfdOnboarding?.oldFlow
? window.nfdOnboarding.oldFlow
: DEFAULT_FLOW;

const switchFlow = ( newFlow ) => {
if ( ! validateFlow( brandConfig, newFlow ) ) {
return false;
}
const currentFlow = window.nfdOnboarding.currentFlow;
const getData = resolveGetDataForFlow( newFlow );
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 = newFlow;
currentData.activeFlow = newFlow;
setCurrentOnboardingData( currentData );
if ( SITEGEN_FLOW !== newFlow ) {
updateInitialize( true );
}
navigate( data.steps[ 1 ].path );
};
const handleRetry = ( ) => {

Check failure on line 84 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Delete `·`
updateSiteGenErrorStatus( false );
window.location.reload();
};
return (
<CommonLayout className="nfd-onboarding-step--site-gen__error">
<div className="nfd-onboarding-step--site-gen__error__container">
<div className="nfd-onboarding-step--site-gen__error__container__orb">
<OrbAnimation height={ `100px` } />
</div>
<div className="nfd-onboarding-step--site-gen__error__container__heading">
<p className="nfd-onboarding-step--site-gen__error__container__heading__text">
{ content.heading }
</p>
</div>
<div className="nfd-onboarding-step--site-gen__error__container__sub-heading">
<p className="nfd-onboarding-step--site-gen__error__container__sub-heading__text">
{ content.subHeading }
</p>
<p className="nfd-onboarding-step--site-gen__error__container__sub-heading__message">
{ content.message }
<a
className="nfd-onboarding-step--site-gen__error__container__sub-heading__exit"
href={ pluginDashboardPage }>

Check failure on line 107 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Insert `⏎↹↹↹↹↹↹`
{ content.buttonExit }
</a>

Check failure on line 109 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Delete `⏎`

</p>
</div>
<div className="nfd-onboarding-step--site-gen__error__container__buttons">
<Button
className="nfd-onboarding-step--site-gen__error__container__buttons__skip"
onClick={ () => {
switchFlow( oldFlow );
} }
>
{ content.buttonSkip }
</Button>
{ isLargeViewport ? (
<Button
className="nfd-onboarding-step--site-gen__error__container__buttons__retry"
onClick={ () => {
handleRetry();
} }
>
<p className="nfd-onboarding-button--site-gen-next--text">{ content.buttonText }</p>

Check failure on line 129 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `{·content.buttonText·}` with `⏎↹↹↹↹↹↹↹↹{·content.buttonText·}⏎↹↹↹↹↹↹↹`
</Button>
) : (
<Fill name={ `${ FOOTER_SITEGEN }/${ FOOTER_END }` }>
<Button
className="nfd-onboarding-step--site-gen__error__container__buttons__retry"
onClick={ () => {
handleRetry();
} }
>
<p className="nfd-onboarding-button--site-gen-next--text">{ content.buttonText }</p>

Check failure on line 139 in src/OnboardingSPA/components/SiteGenError/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `{·content.buttonText·}` with `⏎↹↹↹↹↹↹↹↹↹{·content.buttonText·}⏎↹↹↹↹↹↹↹↹`
</Button>
</Fill>
) }
</div>
</div>
</CommonLayout>
);
};

export default SiteGenSiteError;
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,21 @@

@media (max-width: #{ ($break-small) }) {
margin-right: 0;
}
}
}

&__retry {
height: 50px;
display: flex;
cursor: pointer;
padding: 0 16px;
text-align: center;
border-radius: 8px;
align-items: center;
justify-content: center;
color: var(--nfd-onboarding-secondary);
background-color: var(--nfd-onboarding-primary);
font-size: clamp(0.5rem, 0.3864rem + 0.5682vw, 1.75rem);
}

@media (max-width: #{ ($break-small) }) {
Expand Down
41 changes: 11 additions & 30 deletions src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
import { useSelect, useDispatch } from '@wordpress/data';
import { Fragment, useEffect, useState } from '@wordpress/element';
import { useViewportMatch } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';

import { StepLoader } from '../../Loaders';
import { Fragment } from '@wordpress/element';
import SiteGenSiteError from '../../SiteGenError';
import { useSelect } from '@wordpress/data';
import { store as nfdOnboardingStore } from '../../../store';
import {
expedite,
getThemeStatus,
install as installTheme,
} from '../../../utils/api/themes';
import {
THEME_STATUS_INIT,
THEME_STATUS_INSTALLING,
THEME_STATUS_NOT_ACTIVE,
THEME_STATUS_ACTIVE,
DESIGN_STEPS_THEME,
THEME_STATUS_FAILURE,
} from '../../../../constants';
import { StepErrorState } from '../../ErrorState';
import getContents from './contents';
import ExitToWordPress from '../../ExitToWordPress';

const SitegenAiStateHandler = ( { children, isError = false } ) => {

const SitegenAiStateHandler = ( { children } ) => {
const { siteGenErrorStatus } = useSelect( ( select ) => {
return {
siteGenErrorStatus: select( nfdOnboardingStore ).getSiteGenErrorStatus(),

Check failure on line 9 in src/OnboardingSPA/components/StateHandlers/SitegenAi/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Replace `·` with `⏎↹↹↹↹`
};
} );

const handleRender = () => {
if ( isError ) {
return <StepErrorState
title={ 'title' }
subtitle={ 'subtitle' }
error={ 'error' }
/>;
if ( siteGenErrorStatus ) {
return <SiteGenSiteError />;
}

return children;
Expand Down
33 changes: 18 additions & 15 deletions src/OnboardingSPA/steps/SiteGen/Building/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { store as nfdOnboardingStore } from '../../../store';
import { HEADER_SITEGEN } from '../../../../constants';

import SiteGenLoader from '../../../components/Loaders/SiteGenLoader';
import SitegenAiStateHandler from '../../../components/StateHandlers/SitegenAi';

const SiteGenBuilding = () => {
const {
Expand All @@ -23,22 +24,24 @@ const SiteGenBuilding = () => {
setDrawerActiveView( false );
} );
return (
<CommonLayout
isCentered
className="nfd-onboarding-step--site-gen__building"
>
<div className="site-gen__building_skimmer">
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--header"></div>
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--body"></div>
<div className="site-gen__building_skimmer--footer">
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--footer_left"></div>
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--footer_right"></div>
<SitegenAiStateHandler>
<CommonLayout
isCentered
className="nfd-onboarding-step--site-gen__building"
>
<div className="site-gen__building_skimmer">
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--header"></div>
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--body"></div>
<div className="site-gen__building_skimmer--footer">
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--footer_left"></div>
<div className="site-gen__building_skimmer--main site-gen__building_skimmer--footer_right"></div>
</div>
</div>
</div>
<div className="site-gen__building_loader__overlay">
<SiteGenLoader autoNavigate={ true } />
</div>
</CommonLayout>
<div className="site-gen__building_loader__overlay">
<SiteGenLoader autoNavigate={ true } />
</div>
</CommonLayout>
</SitegenAiStateHandler>
);
};

Expand Down
26 changes: 15 additions & 11 deletions src/OnboardingSPA/steps/SiteGen/Experience/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { store as nfdOnboardingStore } from '../../../store';
import CommonLayout from '../../../components/Layouts/Common';
import CardWithOptions from '../../../components/CardWithOptions';
import SiteGenLoader from '../../../components/Loaders/SiteGenLoader';
import SitegenAiStateHandler from '../../../components/StateHandlers/SitegenAi';

const SiteGenExperience = () => {
const navigate = useNavigate();
Expand Down Expand Up @@ -58,17 +59,20 @@ const SiteGenExperience = () => {
};

return (
<CommonLayout isCentered>
<div className={ 'nfd-sg-experience-level' }>
<SiteGenLoader />
<CardWithOptions
title={ content.heading }
options={ content.options }
skip={ content.skip }
callback={ checkAndNavigate }
/>
</div>
</CommonLayout>
<SitegenAiStateHandler>
<CommonLayout isCentered>
<div className={ 'nfd-sg-experience-level' }>
<SiteGenLoader />
<CardWithOptions
title={ content.heading }
options={ content.options }
skip={ content.skip }
callback={ checkAndNavigate }
/>
</div>
</CommonLayout>
</SitegenAiStateHandler>

Check failure on line 75 in src/OnboardingSPA/steps/SiteGen/Experience/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Delete `⏎`
);
};

Expand Down
7 changes: 3 additions & 4 deletions src/OnboardingSPA/steps/SiteGen/Preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const SiteGenPreview = () => {
const [ isRegenerating, setIsRegenerating ] = useState( false );
const [ isPreviewLoading, setIsPreviewLoading ] = useState( false );
const [ globalStyles, setGlobalStyles ] = useState( false );
const [ isError, setisError ] = useState( false );

const {
setIsHeaderEnabled,
Expand All @@ -32,6 +31,7 @@ const SiteGenPreview = () => {
setCurrentOnboardingData,
updateInitialize,
setHideFooterNav,
updateSiteGenErrorStatus,
} = useDispatch( nfdOnboardingStore );

const { currentData, nextStep } = useSelect( ( select ) => {
Expand Down Expand Up @@ -69,8 +69,7 @@ const SiteGenPreview = () => {

if ( response.error ) {
setIsPreviewLoading( false );
console.log( 'aila' );
setisError( ! isError );
updateSiteGenErrorStatus( true );
return;
}

Expand Down Expand Up @@ -207,7 +206,7 @@ const SiteGenPreview = () => {
const content = getContents();

return (
<SitegenAiStateHandler isError={ isError }>
<SitegenAiStateHandler>
<CommonLayout className="nfd-onboarding-step--site-gen__preview">
<div className="nfd-onboarding-step--site-gen__preview__container">
<div className="nfd-onboarding-step--site-gen__preview__container__heading">
Expand Down
Loading

0 comments on commit ab7fc3e

Please sign in to comment.