2019-03-28 06:09:44 +00:00
|
|
|
|
/** @format */
|
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-07-18 10:11:21 +00:00
|
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
2019-09-02 03:45:56 +00:00
|
|
|
|
import { filter } from 'lodash';
|
2019-08-01 18:09:08 +00:00
|
|
|
|
import { compose } from '@wordpress/compose';
|
2019-07-18 10:11:21 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WooCommerce dependencies
|
|
|
|
|
*/
|
|
|
|
|
import { Card, List } from '@woocommerce/components';
|
2019-07-19 02:54:38 +00:00
|
|
|
|
import { updateQueryString } from '@woocommerce/navigation';
|
2019-03-28 06:09:44 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Internal depdencies
|
|
|
|
|
*/
|
|
|
|
|
import './style.scss';
|
2019-09-02 03:45:56 +00:00
|
|
|
|
import Appearance from './tasks/appearance';
|
2019-08-01 18:09:08 +00:00
|
|
|
|
import Connect from './tasks/connect';
|
2019-07-19 02:54:38 +00:00
|
|
|
|
import Products from './tasks/products';
|
2019-08-21 05:58:47 +00:00
|
|
|
|
import Shipping from './tasks/shipping';
|
2019-08-26 05:49:04 +00:00
|
|
|
|
import Tax from './tasks/tax';
|
2019-08-29 16:41:04 +00:00
|
|
|
|
import Payments from './tasks/payments';
|
2019-08-01 18:09:08 +00:00
|
|
|
|
import withSelect from 'wc-api/with-select';
|
2019-03-28 06:09:44 +00:00
|
|
|
|
|
2019-08-01 18:09:08 +00:00
|
|
|
|
class TaskDashboard extends Component {
|
2019-07-18 10:11:21 +00:00
|
|
|
|
componentDidMount() {
|
2019-08-21 05:58:47 +00:00
|
|
|
|
document.body.classList.add( 'woocommerce-onboarding' );
|
2019-07-18 10:11:21 +00:00
|
|
|
|
document.body.classList.add( 'woocommerce-task-dashboard__body' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
2019-08-21 05:58:47 +00:00
|
|
|
|
document.body.classList.remove( 'woocommerce-onboarding' );
|
2019-07-18 10:11:21 +00:00
|
|
|
|
document.body.classList.remove( 'woocommerce-task-dashboard__body' );
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-01 18:09:08 +00:00
|
|
|
|
getTasks() {
|
2019-09-06 14:18:44 +00:00
|
|
|
|
const { customLogo, hasHomepage, hasProducts, shippingZonesCount } = wcSettings.onboarding;
|
2019-08-01 18:09:08 +00:00
|
|
|
|
const { profileItems, query } = this.props;
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
key: 'connect',
|
|
|
|
|
title: __( 'Connect your store to WooCommerce.com', 'woocommerce-admin' ),
|
2019-08-29 16:41:04 +00:00
|
|
|
|
content: __(
|
2019-08-01 18:09:08 +00:00
|
|
|
|
'Install and manage your extensions directly from your Dashboard',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
before: <i className="material-icons-outlined">extension</i>,
|
|
|
|
|
after: <i className="material-icons-outlined">chevron_right</i>,
|
|
|
|
|
onClick: () => updateQueryString( { task: 'connect' } ),
|
|
|
|
|
container: <Connect query={ query } />,
|
|
|
|
|
visible: profileItems.items_purchased && ! profileItems.wccom_connected,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'products',
|
|
|
|
|
title: __( 'Add your first product', 'woocommerce-admin' ),
|
2019-08-29 16:41:04 +00:00
|
|
|
|
content: __(
|
2019-08-01 18:09:08 +00:00
|
|
|
|
'Add products manually, import from a sheet or migrate from another platform',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
2019-09-06 14:18:44 +00:00
|
|
|
|
before: hasProducts ? (
|
2019-08-01 18:09:08 +00:00
|
|
|
|
<i className="material-icons-outlined">check_circle</i>
|
|
|
|
|
) : (
|
|
|
|
|
<i className="material-icons-outlined">add_box</i>
|
|
|
|
|
),
|
|
|
|
|
after: <i className="material-icons-outlined">chevron_right</i>,
|
|
|
|
|
onClick: () => updateQueryString( { task: 'products' } ),
|
|
|
|
|
container: <Products />,
|
2019-09-06 14:18:44 +00:00
|
|
|
|
className: hasProducts ? 'is-complete' : null,
|
2019-08-01 18:09:08 +00:00
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-09-02 03:45:56 +00:00
|
|
|
|
key: 'appearance',
|
2019-08-01 18:09:08 +00:00
|
|
|
|
title: __( 'Personalize your store', 'woocommerce-admin' ),
|
2019-08-29 16:41:04 +00:00
|
|
|
|
content: __( 'Create a custom homepage and upload your logo', 'wooocommerce-admin' ),
|
2019-08-01 18:09:08 +00:00
|
|
|
|
before: <i className="material-icons-outlined">palette</i>,
|
|
|
|
|
after: <i className="material-icons-outlined">chevron_right</i>,
|
2019-09-02 03:45:56 +00:00
|
|
|
|
onClick: () => updateQueryString( { task: 'appearance' } ),
|
|
|
|
|
container: <Appearance />,
|
2019-09-06 14:18:44 +00:00
|
|
|
|
className: customLogo && hasHomepage ? 'is-complete' : null,
|
2019-08-01 18:09:08 +00:00
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'shipping',
|
|
|
|
|
title: __( 'Set up shipping', 'woocommerce-admin' ),
|
2019-08-29 16:41:04 +00:00
|
|
|
|
content: __( 'Configure some basic shipping rates to get started', 'wooocommerce-admin' ),
|
2019-08-21 05:58:47 +00:00
|
|
|
|
before:
|
|
|
|
|
shippingZonesCount > 0 ? (
|
|
|
|
|
<i className="material-icons-outlined">check_circle</i>
|
|
|
|
|
) : (
|
|
|
|
|
<i className="material-icons-outlined">local_shipping</i>
|
|
|
|
|
),
|
2019-08-01 18:09:08 +00:00
|
|
|
|
after: <i className="material-icons-outlined">chevron_right</i>,
|
2019-08-21 05:58:47 +00:00
|
|
|
|
onClick: () => updateQueryString( { task: 'shipping' } ),
|
|
|
|
|
container: <Shipping />,
|
|
|
|
|
className: shippingZonesCount > 0 ? 'is-complete' : null,
|
2019-08-01 18:09:08 +00:00
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'tax',
|
|
|
|
|
title: __( 'Set up tax', 'woocommerce-admin' ),
|
2019-08-29 16:41:04 +00:00
|
|
|
|
content: __(
|
2019-08-01 18:09:08 +00:00
|
|
|
|
'Choose how to configure tax rates - manually or automatically',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
before: <i className="material-icons-outlined">account_balance</i>,
|
|
|
|
|
after: <i className="material-icons-outlined">chevron_right</i>,
|
2019-08-26 05:49:04 +00:00
|
|
|
|
onClick: () => updateQueryString( { task: 'tax' } ),
|
|
|
|
|
container: <Tax />,
|
2019-08-01 18:09:08 +00:00
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'payments',
|
|
|
|
|
title: __( 'Set up payments', 'woocommerce-admin' ),
|
2019-08-29 16:41:04 +00:00
|
|
|
|
content: __(
|
2019-08-01 18:09:08 +00:00
|
|
|
|
'Select which payment providers you’d like to use and configure them',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
before: <i className="material-icons-outlined">payment</i>,
|
|
|
|
|
after: <i className="material-icons-outlined">chevron_right</i>,
|
2019-08-29 16:41:04 +00:00
|
|
|
|
onClick: () => updateQueryString( { task: 'payments' } ),
|
|
|
|
|
container: <Payments />,
|
2019-08-01 18:09:08 +00:00
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 02:54:38 +00:00
|
|
|
|
getCurrentTask() {
|
|
|
|
|
const { task } = this.props.query;
|
2019-08-01 18:09:08 +00:00
|
|
|
|
const currentTask = this.getTasks().find( s => s.key === task );
|
2019-07-19 02:54:38 +00:00
|
|
|
|
|
|
|
|
|
if ( ! currentTask ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return currentTask;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-28 06:09:44 +00:00
|
|
|
|
render() {
|
2019-07-19 02:54:38 +00:00
|
|
|
|
const currentTask = this.getCurrentTask();
|
2019-08-01 18:09:08 +00:00
|
|
|
|
const tasks = filter( this.getTasks(), task => task.visible );
|
2019-07-19 02:54:38 +00:00
|
|
|
|
|
2019-03-28 06:09:44 +00:00
|
|
|
|
return (
|
2019-07-18 10:11:21 +00:00
|
|
|
|
<Fragment>
|
|
|
|
|
<div className="woocommerce-task-dashboard__container">
|
2019-07-19 02:54:38 +00:00
|
|
|
|
{ currentTask ? (
|
|
|
|
|
currentTask.container
|
|
|
|
|
) : (
|
|
|
|
|
<Card
|
2019-08-21 05:58:47 +00:00
|
|
|
|
className="woocommerce-task-card"
|
2019-07-19 02:54:38 +00:00
|
|
|
|
title={ __( 'Set up your store and start selling', 'woocommerce-admin' ) }
|
|
|
|
|
description={ __(
|
|
|
|
|
'Below you’ll find a list of the most important steps to get your store up and running.',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
>
|
2019-08-01 18:09:08 +00:00
|
|
|
|
<List items={ tasks } />
|
2019-07-19 02:54:38 +00:00
|
|
|
|
</Card>
|
|
|
|
|
) }
|
2019-03-28 06:09:44 +00:00
|
|
|
|
</div>
|
2019-07-18 10:11:21 +00:00
|
|
|
|
</Fragment>
|
2019-03-28 06:09:44 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-01 18:09:08 +00:00
|
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
|
withSelect( select => {
|
|
|
|
|
const { getProfileItems } = select( 'wc-api' );
|
|
|
|
|
const profileItems = getProfileItems();
|
|
|
|
|
return { profileItems };
|
|
|
|
|
} )
|
|
|
|
|
)( TaskDashboard );
|