woocommerce/plugins/woocommerce-admin/client/dashboard/index.js

48 lines
1.0 KiB
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import { Component } from '@wordpress/element';
import { compose } from '@wordpress/compose';
/**
* Internal dependencies
*/
2018-08-02 23:10:55 +00:00
import './style.scss';
import CustomizableDashboard from './customizable';
import ProfileWizard from '../profile-wizard';
import withSelect from 'wc-api/with-select';
import { isOnboardingEnabled } from 'dashboard/utils';
class Dashboard extends Component {
render() {
const { path, profileItems, query } = this.props;
if (
isOnboardingEnabled() &&
! profileItems.completed &&
! window.wcAdminFeatures.homepage
) {
return <ProfileWizard query={ query } />;
}
if ( window.wcAdminFeatures[ 'analytics-dashboard/customizable' ] ) {
return <CustomizableDashboard query={ query } path={ path } />;
}
return null;
}
}
export default compose(
withSelect( ( select ) => {
if ( ! isOnboardingEnabled() ) {
return;
}
const { getProfileItems } = select( 'wc-api' );
const profileItems = getProfileItems();
return { profileItems };
} )
)( Dashboard );