From 0a95f956478150380ac302f0d4096148dcdbc477 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Thu, 29 Feb 2024 15:13:07 +0530 Subject: [PATCH 1/5] Fix missing Progress Bar in certain pages --- .../components/Header/components/SiteGenHeader/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OnboardingSPA/components/Header/components/SiteGenHeader/index.js b/src/OnboardingSPA/components/Header/components/SiteGenHeader/index.js index 186b7b85e..a75ec317f 100644 --- a/src/OnboardingSPA/components/Header/components/SiteGenHeader/index.js +++ b/src/OnboardingSPA/components/Header/components/SiteGenHeader/index.js @@ -10,6 +10,7 @@ import { } from '../../../../../constants'; import { useSelect } from '@wordpress/data'; +import { stepTheFork } from '../../../../steps/TheFork/step'; import { store as nfdOnboardingStore } from '../../../../store'; import StepNavigation from './step-navigation'; @@ -44,7 +45,7 @@ const SiteGenHeader = () => { <> - { isHeaderNavigationEnabled && ( + { currentStep !== stepTheFork && ( ) } From 9c80f5c5e632906e76b77a8cd7b4d34236e69402 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Thu, 29 Feb 2024 15:28:19 +0530 Subject: [PATCH 2/5] Added some comments --- .../NewfoldInterfaceSkeleton/SiteGen/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js index 2bde8c721..c8f0950e2 100644 --- a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js +++ b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js @@ -122,15 +122,19 @@ const SiteGen = () => { skipCache ); if ( data !== null ) { + // A Identifier request was sucessfuly made with valid response currentData.sitegen.siteGenMetaStatus.currentStatus += 1; if ( currentData.sitegen.siteGenMetaStatus.currentStatus === currentData.sitegen.siteGenMetaStatus.totalCount ) { + // Once all requests are completed use cache to get data currentData.sitegen.skipCache = false; } + // Sync the current request changed to State setCurrentOnboardingData( currentData ); + // Sets the Site Title and Taglin in Live Preview if ( identifier === 'site_config' ) { editEntityRecord( 'root', 'site', undefined, { title: data.site_title, @@ -139,6 +143,7 @@ const SiteGen = () => { } } } catch ( err ) { + // Check if it failed then retry again if ( retryCount < MAX_RETRIES_SITE_GEN ) { return performSiteGenMetaGeneration( siteInfo, @@ -148,12 +153,15 @@ const SiteGen = () => { ); } + // If the retry also did not work show the error state setFailedApi( ( prevState ) => { + // If the error doesn't exist add it to the Failed List if ( ! prevState.includes( identifier ) ) { return [ ...prevState, identifier ]; } return prevState; } ); + // Activate the Error Page currentData.sitegen.siteGenErrorStatus = true; setCurrentOnboardingData( currentData ); } @@ -161,7 +169,7 @@ const SiteGen = () => { async function generateSiteGenData() { // Start the API Requests when the loader is shown. - if ( ! location.pathname.includes( 'experience' ) ) { + if ( ! location.pathname.includes( 'site-logo' ) ) { return; } @@ -181,9 +189,9 @@ const SiteGen = () => { identifiers = identifiers.body; currentData.sitegen.siteGenMetaStatus.currentStatus = 0; - setCurrentOnboardingData( currentData ); } + const siteInfo = { site_description: currentData.sitegen?.siteDetails?.prompt, }; From 038d704fe112da5155049a39577edab2071c72a8 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Thu, 29 Feb 2024 15:51:35 +0530 Subject: [PATCH 3/5] Make sure things just work --- .../NewfoldInterfaceSkeleton/SiteGen/index.js | 9 ++- .../steps/SiteGen/SiteLogo/index.js | 79 +++++++++---------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js index c8f0950e2..78f8366c0 100644 --- a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js +++ b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js @@ -167,9 +167,12 @@ const SiteGen = () => { } } - async function generateSiteGenData() { + async function generateSiteGenData( forceRun = false ) { + // ForceRun tells us to bypass the page check or not + // because the requests failed on Logo step is retried in Experience step + // Start the API Requests when the loader is shown. - if ( ! location.pathname.includes( 'site-logo' ) ) { + if ( ! location.pathname.includes( 'site-logo' ) && ! forceRun ) { return; } @@ -286,7 +289,7 @@ const SiteGen = () => { prevSiteGenErrorStatus.current === true && siteGenErrorStatus === false ) { - generateSiteGenData(); + generateSiteGenData( true ); syncStoreToDB(); } prevSiteGenErrorStatus.current = siteGenErrorStatus; diff --git a/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js b/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js index ae14bdffd..52c95fb39 100644 --- a/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js +++ b/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js @@ -11,7 +11,6 @@ import AIHeading from '../../../components/Heading/AIHeading'; import CommonLayout from '../../../components/Layouts/Common'; import NextButtonSiteGen from '../../../components/Button/NextButtonSiteGen'; import ImageUploaderWithText from '../../../components/ImageUploader/components/ImageUploaderWithText'; -import SitegenAiStateHandler from '../../../components/StateHandlers/SitegenAi'; import { OnboardingEvent, trackOnboardingEvent, @@ -99,49 +98,47 @@ const SiteGenSiteLogo = () => { const content = getContents(); return ( - - -
- - +
+ + +
+ resetSiteLogo() } + className="nfd-onboarding-step--site-gen__site-logo__container__buttons__skip" + text={ content.buttons.skip } /> -
- resetSiteLogo() } - className="nfd-onboarding-step--site-gen__site-logo__container__buttons__skip" - text={ content.buttons.skip } - /> - { isLargeViewport && ( - { - if ( siteLogo ) { - trackOnboardingEvent( - new OnboardingEvent( - ACTION_LOGO_ADDED - ), - { - source: SITEGEN_FLOW, - } - ); - } - } } - text={ content.buttons.next } - disabled={ - siteLogo === undefined || siteLogo?.id === 0 - ? true - : false + { isLargeViewport && ( + { + if ( siteLogo ) { + trackOnboardingEvent( + new OnboardingEvent( + ACTION_LOGO_ADDED + ), + { + source: SITEGEN_FLOW, + } + ); } - /> - ) } -
+ } } + text={ content.buttons.next } + disabled={ + siteLogo === undefined || siteLogo?.id === 0 + ? true + : false + } + /> + ) }
- - +
+ ); }; From 39d12b7b34285d36b934d765c7de446baa58bf10 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Thu, 29 Feb 2024 20:01:34 +0530 Subject: [PATCH 4/5] Run homepages magically --- .../NewfoldInterfaceSkeleton/SiteGen/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js index 78f8366c0..5ea9b2e5f 100644 --- a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js +++ b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js @@ -14,6 +14,7 @@ import classNames from 'classnames'; import { setFlow } from '../../../utils/api/flow'; import { generateSiteGenMeta, + getHomepages, getSiteGenIdentifiers, } from '../../../utils/api/siteGen'; import Footer from '../../Footer'; @@ -130,6 +131,20 @@ const SiteGen = () => { ) { // Once all requests are completed use cache to get data currentData.sitegen.skipCache = false; + + // Increase count after site meta calls to ensure systematic call of homepages + currentData.sitegen.siteGenMetaStatus.totalCount += 1; + setCurrentOnboardingData( currentData ); + + // Get the homepages and set that in flow + const response = await getHomepages( + currentData.sitegen.siteDetails.prompt + ); + + if ( response.body ) { + currentData.sitegen.homepages.data = response.body; + } + currentData.sitegen.siteGenMetaStatus.currentStatus += 1; } // Sync the current request changed to State setCurrentOnboardingData( currentData ); From 5a6e99f76aefe8031b9edb50fb5f12aa6f0ea539 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Sat, 2 Mar 2024 11:40:35 +0530 Subject: [PATCH 5/5] Fix Error bug --- .../components/NewfoldInterfaceSkeleton/SiteGen/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js index 5ea9b2e5f..42591ede1 100644 --- a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js +++ b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js @@ -191,6 +191,14 @@ const SiteGen = () => { return; } + // If all the requests have been made already skip this + if ( + currentData.sitegen.siteGenMetaStatus.currentStatus === + currentData.sitegen.siteGenMetaStatus.totalCount + ) { + return; + } + if ( ! window.nfdOnboarding?.siteGenTimerInterval ) { window.nfdOnboarding.siteGenTime = 0; window.nfdOnboarding.siteGenTimerInterval = setInterval( () => {