Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oarding into fix/error-state
  • Loading branch information
arunshenoy99 committed Apr 5, 2024
2 parents 2a93d40 + 10d748b commit 4be2e9d
Show file tree
Hide file tree
Showing 16 changed files with 851 additions and 215 deletions.
63 changes: 37 additions & 26 deletions src/OnboardingSPA/components/StateHandlers/Flow/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
// WordPress
import { useEffect, useState } from '@wordpress/element';
import { useLocation } from 'react-router-dom';
import { useSelect, useDispatch } from '@wordpress/data';
import { getFragment } from '@wordpress/url';

// Third-party
import { useLocation } from 'react-router-dom';
import { HiiveAnalytics } from '@newfold-labs/js-utility-ui-analytics';

import { store as nfdOnboardingStore } from '../../../store';
// Classes and functions
import { switchFlow } from '../../../utils/api/flow';
import { MAX_RETRIES_FLOW_SWITCH } from '../../../../constants';
import {
DEFAULT_FLOW,
ECOMMERCE_FLOW,
SITEGEN_FLOW,
} from '../../../data/flows/constants';
import { removeQueryParam } from '../../../utils';
import { commerce } from '../../../chapters/commerce';
import EcommerceStepLoader from '../../Loaders/Step/Ecommerce';
import SiteBuild from '../../NewfoldInterfaceSkeleton/SiteBuild';
import SiteGen from '../../NewfoldInterfaceSkeleton/SiteGen';
import {
validateFlow,
removeFromAllSteps,
removeFromTopSteps,
removeFromRoutes,
} from '../../../data/flows/utils';
import { resolveGetDataForFlow } from '../../../data/flows';

// Components
import EcommerceStepLoader from '../../Loaders/Step/Ecommerce';
import SiteBuild from '../../NewfoldInterfaceSkeleton/SiteBuild';
import SiteGen from '../../NewfoldInterfaceSkeleton/SiteGen';

// Misc
import { store as nfdOnboardingStore } from '../../../store';
import { MAX_RETRIES_FLOW_SWITCH } from '../../../../constants';
import {
DEFAULT_FLOW,
ECOMMERCE_FLOW,
SITEGEN_FLOW,
} from '../../../data/flows/constants';
import { commerce } from '../../../chapters/commerce';
import { stepTheFork } from '../../../steps/TheFork/step';

const FlowStateHandler = () => {
const location = useLocation();
const [ newFlow, setNewFlow ] = useState( false );

const { brandConfig, onboardingFlow } = useSelect( ( select ) => {
Expand All @@ -47,8 +54,24 @@ const FlowStateHandler = () => {
updateAllSteps,
updateTopSteps,
updateRoutes,
updateInitialize,
} = useDispatch( nfdOnboardingStore );

const location = useLocation();

useEffect( () => {
if ( window.nfdOnboarding?.newFlow ) {
const flow = window.nfdOnboarding.newFlow;
disableNavigation();
setNewFlow( flow );
switchToNewFlow( flow );
window.nfdOnboarding.newFlow = undefined;
} else if ( location.pathname.includes( '/step' ) ) {
setActiveFlow( onboardingFlow );
setActiveStep( location.pathname );
}
}, [ location.pathname ] );

const handleCommerceFlow = async ( flow, retries = 0 ) => {
if ( retries >= MAX_RETRIES_FLOW_SWITCH ) {
return setNewFlow( false );
Expand Down Expand Up @@ -110,22 +133,10 @@ const FlowStateHandler = () => {
stepTheFork,
] );
updateRoutes( updateRoute.routes );
updateInitialize( true );
}
};

useEffect( () => {
if ( window.nfdOnboarding?.newFlow ) {
const flow = window.nfdOnboarding.newFlow;
disableNavigation();
setNewFlow( flow );
switchToNewFlow( flow );
window.nfdOnboarding.newFlow = undefined;
} else if ( location.pathname.includes( '/step' ) ) {
setActiveFlow( onboardingFlow );
setActiveStep( location.pathname );
}
}, [ location.pathname ] );

// TODO: Remove handleRender and replace with only children once Chapter Prioritization is enabled.
const handleRender = () => {
switch ( newFlow ) {
Expand Down
57 changes: 57 additions & 0 deletions tests/cypress/fixtures/color-palette.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[
{
"base": "#2E7D32",
"contrast": "#FFFFFF",
"primary": "#4CAF50",
"tertiary": "#C8E6C9",
"header_background": "#2E7D32",
"header_foreground": "#FFFFFF",
"header_tiles": "#C8E6C9",
"secondary_background": "#FFFFFF",
"secondary_foreground": "#2E7D32"
},
{
"base": "#1565C0",
"contrast": "#FFFFFF",
"primary": "#2196F3",
"tertiary": "#BBDEFB",
"header_background": "#1565C0",
"header_foreground": "#FFFFFF",
"header_tiles": "#BBDEFB",
"secondary_background": "#FFFFFF",
"secondary_foreground": "#1565C0"
},
{
"base": "#6A1B9A",
"contrast": "#FFFFFF",
"primary": "#9C27B0",
"tertiary": "#E1BEE7",
"header_background": "#6A1B9A",
"header_foreground": "#FFFFFF",
"header_tiles": "#E1BEE7",
"secondary_background": "#FFFFFF",
"secondary_foreground": "#6A1B9A"
},
{
"base": "#E65100",
"contrast": "#FFFFFF",
"primary": "#FF5722",
"tertiary": "#FFCCBC",
"header_background": "#E65100",
"header_foreground": "#FFFFFF",
"header_tiles": "#FFCCBC",
"secondary_background": "#FFFFFF",
"secondary_foreground": "#E65100"
},
{
"base": "#FF6F00",
"contrast": "#FFFFFF",
"primary": "#FF9800",
"tertiary": "#FFE0B2",
"header_background": "#FF6F00",
"header_foreground": "#FFFFFF",
"header_tiles": "#FFE0B2",
"secondary_background": "#FFFFFF",
"secondary_foreground": "#FF6F00"
}
]
40 changes: 40 additions & 0 deletions tests/cypress/fixtures/content-structure.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"content_structures": [
{
"structure": [
"header",
"hero",
"headings",
"team",
"features",
"gallery",
"call-to-action",
"footer"
]
},
{
"structure": [
"header",
"hero",
"headings",
"team",
"faq",
"testimonials",
"blog",
"footer"
]
},
{
"structure": [
"header",
"hero",
"headings",
"team",
"gallery",
"call-to-action",
"contact",
"footer"
]
}
]
}
1 change: 1 addition & 0 deletions tests/cypress/fixtures/content-tones.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"tone":"Professional","undertone":"Positive","verbosity":2,"reading_level":60}
47 changes: 47 additions & 0 deletions tests/cypress/fixtures/font-pair.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"aesthetics": "modern",
"font_heading": "jost",
"font_content": "mulish",
"spacing": 2,
"radius": 4,
"font_heading_name": "Jost",
"font_content_name": "Mulish"
},
{
"aesthetics": "minimalist",
"font_heading": "poppins",
"font_content": "source-sans-pro",
"spacing": 1,
"radius": 2,
"font_heading_name": "Poppins",
"font_content_name": "Source Sans Pro"
},
{
"aesthetics": "vintage",
"font_heading": "playfair",
"font_content": "forum",
"spacing": 3,
"radius": 6,
"font_heading_name": "Playfair Display",
"font_content_name": "Forum"
},
{
"aesthetics": "typographic",
"font_heading": "oswald",
"font_content": "merriweather",
"spacing": 2,
"radius": 4,
"font_heading_name": "Oswald",
"font_content_name": "Merriweather"
},
{
"aesthetics": "retro",
"font_heading": "changa-one",
"font_content": "roboto-slab",
"spacing": 2,
"radius": 4,
"font_heading_name": "Changa One",
"font_content_name": "Roboto Slab"
}
]
179 changes: 179 additions & 0 deletions tests/cypress/fixtures/homepages.json

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions tests/cypress/fixtures/plugin-recommendation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"requiredPlugins": [
{
"title": "Yoast SEO",
"description": "Yoast SEO is a comprehensive search engine optimization plugin for WordPress, which offers various features to optimize your site for maximum visibility in search engines.",
"slug": "wordpress-seo",
"path": "wordpress-seo\/wordpress-seo.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/wordpress-seo.zip",
"premium": false,
"requires": []
},
{
"title": "Jetpack",
"description": "Jetpack offers a suite of design, security, and marketing tools for WordPress sites, including real-time backups and easy-to-use performance enhancements.",
"slug": "jetpack",
"path": "jetpack\/jetpack.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/jetpack.zip",
"premium": false,
"requires": []
},
{
"title": "WooCommerce",
"description": "WooCommerce is a customizable, open-source eCommerce platform built on WordPress, allowing users to set up online stores with ease.",
"slug": "woocommerce",
"path": "woocommerce\/woocommerce.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/woocommerce.zip",
"premium": false,
"requires": []
}
],
"recommendedPlugins": [
{
"title": "Creative Mail",
"description": "Creative Mail is an email marketing plugin designed to seamlessly integrate with WordPress, offering intuitive tools for crafting and sending newsletters.",
"slug": "creative-mail-by-constant-contact",
"path": "creative-mail-by-constant-contact\/creative-mail-plugin.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/creative-mail-by-constant-contact.zip",
"premium": false,
"requires": []
},
{
"title": "MonsterInsights",
"description": "MonsterInsights provides a powerful Google Analytics plugin for WordPress, making it easy to connect and view website analytics directly from the dashboard.",
"slug": "google-analytics-for-wordpress",
"path": "google-analytics-for-wordpress\/googleanalytics.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/google-analytics-for-wordpress.zip",
"premium": false,
"requires": []
},
{
"title": "OptinMonster",
"description": "OptinMonster is a lead generation tool for WordPress, offering features like pop-ups, floating bars, and slide-ins to capture user information.",
"slug": "optinmonster",
"path": "optinmonster\/optin-monster-wp-api.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/optinmonster.zip",
"premium": false,
"requires": []
},
{
"title": "WPForms Lite",
"description": "WPForms Lite is a drag-and-drop form builder for WordPress, allowing users to create contact forms, surveys, and more without any coding.",
"slug": "wpforms-lite",
"path": "wpforms-lite\/wpforms.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/wpforms-lite.zip",
"premium": false,
"requires": []
},
{
"title": "YITH Product Search Extended Version",
"description": "An extended version of YITH's product search plugin for WooCommerce, enhancing search capabilities.",
"slug": "yith-product-search-extended",
"path": "yith-product-search-extended\/yith-product-search-extended.php",
"download_url": "https:\/\/downloads.wordpress.org\/plugin\/yith-product-search-extended.zip",
"premium": false,
"requires": []
},
{
"title": "YITH Product Filter Extended Version",
"description": "An extended version of YITH's product filter plugin for WooCommerce, enhancing product filtering capabilities.",
"slug": "nfd_slug_yith_woocommerce_ajax_product_filter",
"path": "yith-woocommerce-ajax-product-filter-extended\/init.php",
"download_url": "https:\/\/hiive.cloud\/workers\/plugin-downloads\/yith-woocommerce-ajax-product-filter",
"premium": false,
"requires": []
},
{
"title": "YITH Bookings Extended Version",
"description": "An extended version of YITH's booking plugin for WooCommerce, allowing users to book products or services.",
"slug": "nfd_slug_yith_woocommerce_booking",
"path": "yith-woocommerce-booking-extended\/init.php",
"download_url": "https:\/\/hiive.cloud\/workers\/plugin-downloads\/yith-woocommerce-booking",
"premium": false,
"requires": []
},
{
"title": "YITH Wishlist Extended Version",
"description": "An extended version of YITH's wishlist plugin for WooCommerce, allowing users to create and manage wishlists.",
"slug": "nfd_slug_yith_woocommerce_wishlist",
"path": "yith-woocommerce-wishlist-extended\/init.php",
"download_url": "https:\/\/hiive.cloud\/workers\/plugin-downloads\/yith-woocommerce-wishlist",
"premium": false,
"requires": []
}
]
}
23 changes: 23 additions & 0 deletions tests/cypress/fixtures/site-classification.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"primaryType": "business",
"slug": "shopping-retail",
"emoji": "\ud83c\udfec",
"wooType": "other",
"schema": "Store",
"keywords": [
"commerce",
"brick-and-mortar",
"discounts",
"coupons",
"customer",
"product",
"loyalty",
"inventory",
"shipping",
"returns",
"cross-sell",
"upsell",
"gift cards"
],
"label": "Shopping & Retail"
}
4 changes: 4 additions & 0 deletions tests/cypress/fixtures/site-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"site_title": "Asana Yoga Studio",
"tagline": "Elevate your practice with sustainable yoga essentials"
}
Loading

0 comments on commit 4be2e9d

Please sign in to comment.