2020-04-27 14:56:15 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { compose } from '@wordpress/compose';
|
2020-04-29 18:01:27 +00:00
|
|
|
import { Suspense, lazy } from '@wordpress/element';
|
2020-05-28 08:51:40 +00:00
|
|
|
import { identity } from 'lodash';
|
2020-04-29 18:01:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce dependencies
|
|
|
|
*/
|
2020-05-28 08:51:40 +00:00
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
2020-04-29 18:01:27 +00:00
|
|
|
import { Spinner } from '@woocommerce/components';
|
2020-05-28 08:51:40 +00:00
|
|
|
import {
|
|
|
|
ONBOARDING_STORE_NAME,
|
|
|
|
withOnboardingHydration,
|
|
|
|
} from '@woocommerce/data';
|
2020-04-27 14:56:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import withSelect from 'wc-api/with-select';
|
|
|
|
import { isOnboardingEnabled } from 'dashboard/utils';
|
|
|
|
|
2020-04-29 18:01:27 +00:00
|
|
|
const ProfileWizard = lazy( () =>
|
|
|
|
import( /* webpackChunkName: "profile-wizard" */ '../profile-wizard' )
|
|
|
|
);
|
2020-05-12 23:14:08 +00:00
|
|
|
import Layout from './layout';
|
2020-04-29 18:01:27 +00:00
|
|
|
|
2020-04-27 14:56:15 +00:00
|
|
|
const Homepage = ( { profileItems, query } ) => {
|
|
|
|
if ( isOnboardingEnabled() && ! profileItems.completed ) {
|
2020-04-29 18:01:27 +00:00
|
|
|
return (
|
|
|
|
<Suspense fallback={ <Spinner /> }>
|
|
|
|
<ProfileWizard query={ query } />
|
|
|
|
</Suspense>
|
|
|
|
);
|
2020-04-27 14:56:15 +00:00
|
|
|
}
|
|
|
|
|
2020-05-21 17:15:08 +00:00
|
|
|
return <Layout query={ query } />;
|
2020-04-22 21:32:44 +00:00
|
|
|
};
|
|
|
|
|
2020-04-27 14:56:15 +00:00
|
|
|
export default compose(
|
2020-05-28 08:51:40 +00:00
|
|
|
getSetting( 'onboarding', {} ).profile
|
|
|
|
? withOnboardingHydration( getSetting( 'onboarding', {} ).profile )
|
|
|
|
: identity,
|
2020-04-27 14:56:15 +00:00
|
|
|
withSelect( ( select ) => {
|
|
|
|
if ( ! isOnboardingEnabled() ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-28 08:51:40 +00:00
|
|
|
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
|
2020-04-27 14:56:15 +00:00
|
|
|
const profileItems = getProfileItems();
|
|
|
|
|
|
|
|
return { profileItems };
|
|
|
|
} )
|
|
|
|
)( Homepage );
|