diff --git a/build/index.asset.php b/build/index.asset.php index 94ef4393..484345cd 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '48ad4ec1646d7a93d94d'); + array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'fa04bc00a67c691890f2'); diff --git a/src/index.js b/src/index.js index 276d38ff..a7846aca 100644 --- a/src/index.js +++ b/src/index.js @@ -1,16 +1,16 @@ -import { NewfoldRuntime } from './sdk/NewfoldRuntime'; -import apiFetch from '@wordpress/api-fetch'; -import { Spinner } from '@newfold/ui-component-library'; -import { __ } from '@wordpress/i18n'; -import useSWR, { SWRConfig } from 'swr'; -import { Products } from './components/ProductsAndServices'; -import { Store } from './components/Store'; -import { StoreDetails } from './components/StoreDetails'; -import { WonderCart } from './components/WonderCart'; -import { PluginsSdk } from './sdk/plugins'; -import { AllPayments } from './components/AllPayments'; -import domReady from '@wordpress/dom-ready'; -import { AnalyticsSdk } from './sdk/analytics'; +import { NewfoldRuntime } from "./sdk/NewfoldRuntime"; +import apiFetch from "@wordpress/api-fetch"; +import { Spinner } from "@newfold/ui-component-library"; +import { __ } from "@wordpress/i18n"; +import useSWR, { SWRConfig } from "swr"; +import { Products } from "./components/ProductsAndServices"; +import { Store } from "./components/Store"; +import { StoreDetails } from "./components/StoreDetails"; +import { WonderCart } from "./components/WonderCart"; +import { PluginsSdk } from "./sdk/plugins"; +import { AllPayments } from "./components/AllPayments"; +import domReady from "@wordpress/dom-ready"; +import { AnalyticsSdk } from "./sdk/analytics"; const fetcher = (path) => apiFetch({ url: NewfoldRuntime.createApiUrl(path) }); @@ -19,26 +19,26 @@ domReady(() => { }); const pages = [ - { key: '/store', Page: Store }, - { key: '/store/products', Page: Products }, - { key: '/store/details', Page: StoreDetails }, - { key: '/store/sales_discounts', Page: WonderCart }, - { key: '/store/payments', Page: AllPayments }, + { key: "/store", Page: Store }, + { key: "/store/products", Page: Products }, + { key: "/store/details", Page: StoreDetails }, + { key: "/store/sales_discounts", Page: WonderCart }, + { key: "/store/payments", Page: AllPayments }, ]; function parseWCStatus(data) { const status = data?.details?.woocommerce?.status; - const isActive = status === 'active'; - const needsInstall = status === 'need_to_install'; - const isInstalling = data?.queue?.includes('woocommerce'); + const isActive = status === "active"; + const needsInstall = status === "need_to_install"; + const isInstalling = data?.queue?.includes("woocommerce"); return { isActive, needsInstall, isInstalling }; } /** @type {import("..").NewfoldEcommerce} */ export function NewfoldECommerce(props) { let { data: woo, mutate } = useSWR( - 'woo-status', - () => PluginsSdk.queries.status('woocommerce').then(parseWCStatus), + "woo-status", + () => PluginsSdk.queries.status("woocommerce").then(parseWCStatus), { revalidateOnReconnect: false, refreshInterval: 30 * 1000 } ); let { Page } = @@ -46,16 +46,17 @@ export function NewfoldECommerce(props) { let { notify } = props.wpModules; useEffect(() => { - sessionStorage.getItem('reload') === 'true' && - notify.push('woo-install-status', { + sessionStorage.getItem("reload") === "true" && + sessionStorage.getItem("woo") === "true" && + notify.push("woo-install-status", { title: __( - 'WooCommerce has been installed successfully', - 'wp-module-ecommerce' + "WooCommerce has been installed successfully", + "wp-module-ecommerce" ), - variant: 'success', + variant: "success", autoDismiss: 5000, }); - sessionStorage.setItem('reload', 'false'); + sessionStorage.setItem("reload", "false"); }, []); if (woo === undefined) { @@ -67,9 +68,11 @@ export function NewfoldECommerce(props) { } if (!woo.isActive) { Page = Store; - sessionStorage.setItem('reload', 'true'); + sessionStorage.setItem("reload", "true"); + sessionStorage.setItem("woo", "false"); } else { - if (sessionStorage.getItem('reload') === 'true') { + sessionStorage.setItem("woo", "true"); + if (sessionStorage.getItem("reload") === "true") { window.location.reload(); } } @@ -86,5 +89,5 @@ export function NewfoldECommerce(props) { ); } -export * from './components/FreePlugins'; -export * from './components/OnboardingScreen'; +export * from "./components/FreePlugins"; +export * from "./components/OnboardingScreen";