2020-04-27 14:56:15 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { compose } from '@wordpress/compose';
|
2020-08-05 00:14:56 +00:00
|
|
|
import { withSelect } from '@wordpress/data';
|
2020-05-28 08:51:40 +00:00
|
|
|
import { identity } from 'lodash';
|
2020-04-29 18:01:27 +00:00
|
|
|
|
2020-05-28 08:51:40 +00:00
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
|
|
|
import {
|
|
|
|
ONBOARDING_STORE_NAME,
|
|
|
|
withOnboardingHydration,
|
|
|
|
} from '@woocommerce/data';
|
2020-07-16 15:17:10 +00:00
|
|
|
import { getHistory, getNewPath } from '@woocommerce/navigation';
|
2020-04-27 14:56:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-08-13 02:05:22 +00:00
|
|
|
import { isOnboardingEnabled } from '../dashboard/utils';
|
2020-05-12 23:14:08 +00:00
|
|
|
import Layout from './layout';
|
2020-04-29 18:01:27 +00:00
|
|
|
|
2020-06-15 02:17:12 +00:00
|
|
|
const Homescreen = ( { profileItems, query } ) => {
|
2020-07-16 15:17:10 +00:00
|
|
|
const { completed: profilerCompleted, skipped: profilerSkipped } =
|
|
|
|
profileItems || {};
|
|
|
|
if ( isOnboardingEnabled() && ! profilerCompleted && ! profilerSkipped ) {
|
|
|
|
getHistory().push( getNewPath( {}, `/profiler`, {} ) );
|
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 };
|
|
|
|
} )
|
2020-06-15 02:17:12 +00:00
|
|
|
)( Homescreen );
|