From 7d1eff13428f5f61349d6971fb1384b8ec014d33 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 7 Feb 2023 19:42:43 +0530 Subject: [PATCH] re-check active theme on API failure and throw a confirmation dialogue --- .../components/Drawer/DrawerPanel/DesignColors.js | 4 ++-- .../components/Drawer/DrawerPanel/DesignHeaderMenu.js | 4 ++-- .../Drawer/DrawerPanel/DesignThemeStylesPreview.js | 6 +++--- .../components/Drawer/DrawerPanel/DesignTypography.js | 4 ++-- .../components/LivePreview/GlobalStylesProvider/index.js | 4 ++-- src/OnboardingSPA/pages/Steps/DesignColors/index.js | 4 ++-- src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js | 4 ++-- .../pages/Steps/DesignThemeStyles/Menu/index.js | 6 +++--- .../pages/Steps/DesignThemeStyles/Preview/index.js | 4 ++-- src/OnboardingSPA/pages/Steps/DesignTypography/index.js | 4 ++-- src/OnboardingSPA/pages/Steps/SitePages/index.js | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignColors.js b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignColors.js index 17290fc5b..85d9923b3 100644 --- a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignColors.js +++ b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignColors.js @@ -9,7 +9,7 @@ import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-s import { GlobalStylesProvider } from '../../LivePreview'; import { THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, } from '../../../../constants'; import Animate from '../../Animate'; @@ -200,7 +200,7 @@ const DesignColors = () => { const getColorStylesAndPatterns = async () => { const colorPalettes = await getThemeColors(); if ( colorPalettes?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setColorPalettes( colorPalettes?.body ); let selectedColors; diff --git a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js index 3b60159bf..718294429 100644 --- a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js +++ b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js @@ -8,7 +8,7 @@ import { GlobalStylesProvider } from '../../../components/LivePreview'; import { THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, } from '../../../../constants'; const DesignHeaderMenu = () => { @@ -48,7 +48,7 @@ const DesignHeaderMenu = () => { currentStep.patternId ); if ( headerMenuPreviewResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setHeaderMenuPreviewData( headerMenuPreviewResponse.body ); diff --git a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignThemeStylesPreview.js b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignThemeStylesPreview.js index 239fc7388..87290e71e 100644 --- a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignThemeStylesPreview.js +++ b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignThemeStylesPreview.js @@ -7,7 +7,7 @@ import { getGlobalStyles } from '../../../utils/api/themes'; import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-styles-output'; import { THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, } from '../../../../constants'; import { LivePreviewSelectableCard, @@ -50,11 +50,11 @@ const DesignThemeStylesPreview = () => { true ); if ( patternResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } const globalStylesResponse = await getGlobalStyles( true ); if ( globalStylesResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setPattern( patternResponse?.body ); setGlobalStyles( globalStylesResponse?.body ); diff --git a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js index 98034460e..fe1a1fad6 100644 --- a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js +++ b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js @@ -8,7 +8,7 @@ import { getGlobalStyles, getThemeFonts } from '../../../utils/api/themes'; import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-styles-output'; import { THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, } from '../../../../constants'; const DesignTypography = () => { @@ -41,7 +41,7 @@ const DesignTypography = () => { const getFontStylesAndPatterns = async () => { const fontPalettes = await getThemeFonts(); if ( fontPalettes?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setFontPalettes( fontPalettes?.body ); diff --git a/src/OnboardingSPA/components/LivePreview/GlobalStylesProvider/index.js b/src/OnboardingSPA/components/LivePreview/GlobalStylesProvider/index.js index 3830e409a..1bde8d637 100644 --- a/src/OnboardingSPA/components/LivePreview/GlobalStylesProvider/index.js +++ b/src/OnboardingSPA/components/LivePreview/GlobalStylesProvider/index.js @@ -6,7 +6,7 @@ import { getGlobalStyles, setGlobalStyles } from '../../../utils/api/themes'; import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-styles-output'; import { THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, } from '../../../../constants'; /** @@ -39,7 +39,7 @@ const GlobalStylesProvider = ( { children } ) => { const getStylesAndPatterns = async () => { const globalStyles = await getGlobalStyles(); if ( globalStyles?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } let selectedGlobalStyle; if ( storedPreviewSettings?.title && storedPreviewSettings?.settings ) diff --git a/src/OnboardingSPA/pages/Steps/DesignColors/index.js b/src/OnboardingSPA/pages/Steps/DesignColors/index.js index c60b0b5f4..8ec7c6760 100644 --- a/src/OnboardingSPA/pages/Steps/DesignColors/index.js +++ b/src/OnboardingSPA/pages/Steps/DesignColors/index.js @@ -13,7 +13,7 @@ import { import { SIDEBAR_LEARN_MORE, THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, VIEW_DESIGN_COLORS, } from '../../../../constants'; @@ -42,7 +42,7 @@ const StepDesignColors = () => { const getStylesAndPatterns = async () => { const pattern = await getPatterns( currentStep.patternId, true ); if ( pattern?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setPattern( pattern?.body ); setIsLoaded( true ); diff --git a/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js b/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js index fa1ebe985..1d8a9d1f1 100644 --- a/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js +++ b/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js @@ -8,7 +8,7 @@ import CommonLayout from '../../../components/Layouts/Common'; import { VIEW_NAV_DESIGN, THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, SIDEBAR_LEARN_MORE, } from '../../../../constants'; import HeadingWithSubHeading from '../../../components/HeadingWithSubHeading'; @@ -103,7 +103,7 @@ const StepDesignHomepageMenu = () => { async function getHomepagePatternsData() { const homepagePatternData = await getPatterns( currentStep.patternId ); if ( homepagePatternData?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setHomepagePattern( refactorPatterns( homepagePatternData ) ); diff --git a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js index 89fadac82..c7a09775b 100644 --- a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js +++ b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js @@ -11,7 +11,7 @@ import { getGlobalStyles } from '../../../../utils/api/themes'; import { VIEW_NAV_DESIGN, THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, SIDEBAR_LEARN_MORE, } from '../../../../../constants'; import { DesignStateHandler } from '../../../../components/StateHandlers'; @@ -69,11 +69,11 @@ const StepDesignThemeStylesMenu = () => { true ); if ( patternsResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } const globalStylesResponse = await getGlobalStyles( true ); if ( globalStylesResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setPattern( patternsResponse?.body ); setGlobalStyles( globalStylesResponse?.body ); diff --git a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js index a4d5b7479..0f05240d7 100644 --- a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js +++ b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js @@ -13,7 +13,7 @@ import CommonLayout from '../../../../components/Layouts/Common'; import { VIEW_DESIGN_THEME_STYLES_PREVIEW, THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, SIDEBAR_LEARN_MORE, } from '../../../../../constants'; import { store as nfdOnboardingStore } from '../../../../store'; @@ -70,7 +70,7 @@ const StepDesignThemeStylesPreview = () => { true ); if ( patternsResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setPattern( patternsResponse?.body ); setIsLoaded( true ); diff --git a/src/OnboardingSPA/pages/Steps/DesignTypography/index.js b/src/OnboardingSPA/pages/Steps/DesignTypography/index.js index 706834b0e..7e0c3cafe 100644 --- a/src/OnboardingSPA/pages/Steps/DesignTypography/index.js +++ b/src/OnboardingSPA/pages/Steps/DesignTypography/index.js @@ -7,7 +7,7 @@ import { store as nfdOnboardingStore } from '../../../store'; import CommonLayout from '../../../components/Layouts/Common'; import { SIDEBAR_LEARN_MORE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, VIEW_DESIGN_TYPOGRAPHY, THEME_STATUS_ACTIVE, } from '../../../../constants'; @@ -45,7 +45,7 @@ const StepDesignTypography = () => { true ); if ( patternsResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } setPattern( patternsResponse?.body ); setIsLoaded( true ); diff --git a/src/OnboardingSPA/pages/Steps/SitePages/index.js b/src/OnboardingSPA/pages/Steps/SitePages/index.js index 5586fef5d..cc7a4e907 100644 --- a/src/OnboardingSPA/pages/Steps/SitePages/index.js +++ b/src/OnboardingSPA/pages/Steps/SitePages/index.js @@ -8,7 +8,7 @@ import HeadingWithSubHeading from '../../../components/HeadingWithSubHeading'; import { getPatterns } from '../../../utils/api/patterns'; import { THEME_STATUS_ACTIVE, - THEME_STATUS_FAILURE, + THEME_STATUS_INIT, SIDEBAR_LEARN_MORE, VIEW_NAV_DESIGN, } from '../../../../constants'; @@ -54,7 +54,7 @@ const StepSitePages = () => { const getSitePages = async () => { const sitePagesResponse = await getPatterns( currentStep.patternId ); if ( sitePagesResponse?.error ) { - return updateThemeStatus( THEME_STATUS_FAILURE ); + return updateThemeStatus( THEME_STATUS_INIT ); } if ( sitePagesResponse?.body ) { setSitePages( sitePagesResponse.body );