From 84db458390bf70ea640885bda90fa5d1c6cb8a8d Mon Sep 17 00:00:00 2001
From: Allen Benny <48691514+officiallygod@users.noreply.github.com>
Date: Thu, 2 Mar 2023 12:18:47 +0530
Subject: [PATCH 1/6] Basic Dynamic Exit Link
---
includes/Data/Brands.php | 2 ++
src/OnboardingSPA/components/Button/NavCardButton/index.js | 4 ++--
src/OnboardingSPA/components/ExitToWordPress/index.js | 4 ++--
src/OnboardingSPA/components/Header/step-navigation.js | 4 ++--
src/OnboardingSPA/components/SkipButton/index.js | 4 ++--
src/constants.js | 2 +-
6 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php
index f7add3595..78cf67bcc 100644
--- a/includes/Data/Brands.php
+++ b/includes/Data/Brands.php
@@ -29,6 +29,7 @@ public static function get_brands() {
'accountUrl' => 'https://my.bluehost.com',
'domainsUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/domains',
'emailUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/email-office',
+ 'dashboardUrl' => '?page=bluehost',
'phoneNumbers' => array(
'sales' => '844-303-1730',
'support' => '888-401-4678',
@@ -82,6 +83,7 @@ public static function get_brands() {
'accountUrl' => 'https://my.bluehost.in',
'domainsUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/domains',
'emailUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/email-office',
+ 'dashboardUrl' => '?page=bluehost',
'hireExpertsInfo' => array(
'defaultLink' => 'https://www.bluehost.in/solutions/full-service',
'utmParameters' => array(
diff --git a/src/OnboardingSPA/components/Button/NavCardButton/index.js b/src/OnboardingSPA/components/Button/NavCardButton/index.js
index 3872897af..1af6ee87e 100644
--- a/src/OnboardingSPA/components/Button/NavCardButton/index.js
+++ b/src/OnboardingSPA/components/Button/NavCardButton/index.js
@@ -4,7 +4,7 @@ import { store as nfdOnboardingStore } from '../../../store';
import Button from '../../Button';
import { setFlow } from '../../../utils/api/flow';
-import { wpAdminPage, bluehostDashboardPage } from '../../../../constants';
+import { wpAdminPage, dashboardPage } from '../../../../constants';
/**
* Navigation Button Component on Card
@@ -37,7 +37,7 @@ const NavCardButton = ( { text, disabled } ) => {
//Redirect to Admin Page for normal customers
// and Bluehost Dashboard for ecommerce customers
const exitLink = exitToWordpressForEcommerce()
- ? bluehostDashboardPage
+ ? dashboardPage
: wpAdminPage;
window.location.replace( exitLink );
}
diff --git a/src/OnboardingSPA/components/ExitToWordPress/index.js b/src/OnboardingSPA/components/ExitToWordPress/index.js
index 09285f463..eaac7078c 100644
--- a/src/OnboardingSPA/components/ExitToWordPress/index.js
+++ b/src/OnboardingSPA/components/ExitToWordPress/index.js
@@ -9,7 +9,7 @@ import classNames from 'classnames';
import { setFlow } from '../../utils/api/flow';
import { store as nfdOnboardingStore } from '../../store';
import { getSettings, setSettings } from '../../utils/api/settings';
-import { wpAdminPage, bluehostDashboardPage } from '../../../constants';
+import { wpAdminPage, dashboardPage } from '../../../constants';
/**
* Self-contained button and confirmation modal for exiting Onboarding page.
@@ -90,7 +90,7 @@ const ExitToWordPress = ( {
//Redirect to Admin Page for normal customers
// and Bluehost Dashboard for ecommerce customers
const exitLink = exitToWordpressForEcommerce()
- ? bluehostDashboardPage
+ ? dashboardPage
: wpAdminPage;
window.location.replace( exitLink );
}
diff --git a/src/OnboardingSPA/components/Header/step-navigation.js b/src/OnboardingSPA/components/Header/step-navigation.js
index 6ac1fc434..17fba34e0 100644
--- a/src/OnboardingSPA/components/Header/step-navigation.js
+++ b/src/OnboardingSPA/components/Header/step-navigation.js
@@ -6,7 +6,7 @@ import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { setFlow } from '../../utils/api/flow';
import { store as nfdOnboardingStore } from '../../store';
-import { wpAdminPage, bluehostDashboardPage } from '../../../constants';
+import { wpAdminPage, dashboardPage } from '../../../constants';
/**
* Back step Navigation button.
@@ -61,7 +61,7 @@ async function saveDataAndExit( currentData ) {
//Redirect to Admin Page for normal customers
// and Bluehost Dashboard for ecommerce customers
const exitLink = exitToWordpressForEcommerce()
- ? bluehostDashboardPage
+ ? dashboardPage
: wpAdminPage;
window.location.replace( exitLink );
}
diff --git a/src/OnboardingSPA/components/SkipButton/index.js b/src/OnboardingSPA/components/SkipButton/index.js
index 995b71d7d..ee5989187 100644
--- a/src/OnboardingSPA/components/SkipButton/index.js
+++ b/src/OnboardingSPA/components/SkipButton/index.js
@@ -7,7 +7,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { setFlow } from '../../utils/api/flow';
import { store as nfdOnboardingStore } from '../../store';
import { getSettings, setSettings } from '../../utils/api/settings';
-import { wpAdminPage, bluehostDashboardPage } from '../../../constants';
+import { wpAdminPage, dashboardPage } from '../../../constants';
/**
* Interface Text Inputs with standard design.
@@ -56,7 +56,7 @@ const SkipButton = () => {
// Redirect to Admin Page for normal customers
// and Bluehost Dashboard for ecommerce customers
const exitLink = exitToWordpressForEcommerce()
- ? bluehostDashboardPage
+ ? dashboardPage
: wpAdminPage;
window.location.replace( exitLink );
}
diff --git a/src/constants.js b/src/constants.js
index 36d2121d0..b8008b7a9 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -10,7 +10,7 @@ export const onboardingRestRoute = 'newfold-onboarding/v1';
export const wpRestBase = `${ wpRestURL }/${ wpRestRoute }`;
export const onboardingRestBase = `${ wpRestURL }/${ onboardingRestRoute }`;
export const wpAdminPage = `${ wpAdminUrl }index.php`;
-export const bluehostDashboardPage = `${ wpAdminPage }?page=bluehost`;
+export const dashboardPage = `${ wpAdminPage }${ window?.nfdOnboarding?.currentBrand?.dashboardUrl }`;
export const NFD_ONBOARDING_EVENT_PREFIX = 'nfd-module-onboarding-event';
export const VIEW_NAV_PRIMARY = 'nav-primary';
export const VIEW_NAV_DESIGN = 'nav-design';
From edb0d6c8d104f0de5eb85ee00dc272ade4170c79 Mon Sep 17 00:00:00 2001
From: Allen Benny <48691514+officiallygod@users.noreply.github.com>
Date: Thu, 2 Mar 2023 15:57:36 +0530
Subject: [PATCH 2/6] Linting JS
---
.../components/ExitToWordPress/index.js | 18 +++++++---------
.../components/Header/step-navigation.js | 21 ++++++++++---------
.../components/SkipButton/index.js | 16 +++++++-------
3 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/src/OnboardingSPA/components/ExitToWordPress/index.js b/src/OnboardingSPA/components/ExitToWordPress/index.js
index eaac7078c..dd6827da8 100644
--- a/src/OnboardingSPA/components/ExitToWordPress/index.js
+++ b/src/OnboardingSPA/components/ExitToWordPress/index.js
@@ -15,7 +15,8 @@ import { wpAdminPage, dashboardPage } from '../../../constants';
* Self-contained button and confirmation modal for exiting Onboarding page.
*
* @param {*} param0
- * @return
+ *
+ * @return {WPComponent} ExitToWordPress Component
*/
const ExitToWordPress = ( {
buttonText = __( 'Exit to WordPress', 'wp-module-onboarding' ),
@@ -62,7 +63,7 @@ const ExitToWordPress = ( {
);
}
- async function syncSocialSettingsFinish( currentData ) {
+ async function syncSocialSettingsFinish() {
const initialData = await getSettings();
const result = await setSettings( currentData?.data?.socialData );
if ( result?.error !== null ) {
@@ -71,19 +72,18 @@ const ExitToWordPress = ( {
return result?.body;
}
- async function saveData( path, currentData ) {
+ async function saveData( path ) {
if ( currentData ) {
currentData.hasExited = new Date().getTime();
// If Social Data is changed then sync it
if ( path?.includes( 'basic-info' ) ) {
- const socialData = await syncSocialSettingsFinish(
- currentData
- );
+ const socialData = await syncSocialSettingsFinish();
// If Social Data is changed then Sync that also to the store
- if ( socialData && currentData?.data )
+ if ( socialData && currentData?.data ) {
currentData.data.socialData = socialData;
+ }
}
setFlow( currentData );
}
@@ -125,9 +125,7 @@ const ExitToWordPress = ( {
diff --git a/src/OnboardingSPA/components/Header/step-navigation.js b/src/OnboardingSPA/components/Header/step-navigation.js
index 17fba34e0..d967552d9 100644
--- a/src/OnboardingSPA/components/Header/step-navigation.js
+++ b/src/OnboardingSPA/components/Header/step-navigation.js
@@ -12,7 +12,8 @@ import { wpAdminPage, dashboardPage } from '../../../constants';
* Back step Navigation button.
*
* @param {*} param0
- * @return
+ *
+ * @return {WPComponent} Back Component
*/
const Back = ( { path } ) => {
const navigate = useNavigate();
@@ -34,7 +35,8 @@ const Back = ( { path } ) => {
* Next step naigation button
*
* @param {*} param0
- * @return
+ *
+ * @return {WPComponent} Next Component
*/
const Next = ( { path } ) => {
/* [TODO]: some sense of isStepComplete to enable/disable */
@@ -69,14 +71,13 @@ async function saveDataAndExit( currentData ) {
/**
* Finish step navigation button.
*
- * @param root0
- * @param root0.currentData
- * @param root0.saveDataAndExit
- * @return
+ * @param {*} param0
+ *
+ * @return {WPComponent} Finish Component
*/
-const Finish = ( { currentData, saveDataAndExit } ) => (
+const Finish = ( { currentData, saveDataAndExitFunc } ) => (