2019-03-28 06:09:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2020-03-15 21:45:19 +00:00
|
|
|
|
import { Component, cloneElement, Fragment } from '@wordpress/element';
|
2020-03-23 20:47:12 +00:00
|
|
|
|
import { get, isEqual } from 'lodash';
|
2019-08-01 18:09:08 +00:00
|
|
|
|
import { compose } from '@wordpress/compose';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
import classNames from 'classnames';
|
2019-11-01 04:00:57 +00:00
|
|
|
|
import { Snackbar, Icon, Button, Modal } from '@wordpress/components';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
import { withDispatch } from '@wordpress/data';
|
2019-07-18 10:11:21 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WooCommerce dependencies
|
|
|
|
|
*/
|
2019-10-11 12:55:35 +00:00
|
|
|
|
import { Card, List, MenuItem, EllipsisMenu } from '@woocommerce/components';
|
2019-07-19 02:54:38 +00:00
|
|
|
|
import { updateQueryString } from '@woocommerce/navigation';
|
2020-03-02 22:22:32 +00:00
|
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
2019-03-28 06:09:44 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2019-11-14 14:35:55 +00:00
|
|
|
|
* Internal dependencies
|
2019-03-28 06:09:44 +00:00
|
|
|
|
*/
|
|
|
|
|
import './style.scss';
|
2019-12-31 08:50:45 +00:00
|
|
|
|
import CartModal from '../components/cart-modal';
|
|
|
|
|
import { getAllTasks } from './tasks';
|
2019-10-07 20:27:34 +00:00
|
|
|
|
import { recordEvent } from 'lib/tracks';
|
2019-12-31 08:50:45 +00:00
|
|
|
|
import withSelect from 'wc-api/with-select';
|
2019-09-23 21:47:08 +00:00
|
|
|
|
|
2019-08-01 18:09:08 +00:00
|
|
|
|
class TaskDashboard extends Component {
|
2019-11-01 04:00:57 +00:00
|
|
|
|
constructor( props ) {
|
|
|
|
|
super( props );
|
|
|
|
|
this.state = {
|
2019-12-31 08:50:45 +00:00
|
|
|
|
isCartModalOpen: false,
|
2019-11-01 04:00:57 +00:00
|
|
|
|
isWelcomeModalOpen: ! props.modalDismissed,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 10:11:21 +00:00
|
|
|
|
componentDidMount() {
|
2020-03-23 20:47:12 +00:00
|
|
|
|
const { incompleteTasks, updateOptions } = this.props;
|
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' );
|
2019-10-07 20:27:34 +00:00
|
|
|
|
|
2019-10-29 02:08:39 +00:00
|
|
|
|
this.recordTaskView();
|
|
|
|
|
this.recordTaskListView();
|
2019-10-21 00:33:46 +00:00
|
|
|
|
|
2020-03-23 20:47:12 +00:00
|
|
|
|
if ( ! incompleteTasks.length ) {
|
|
|
|
|
updateOptions( {
|
2019-10-21 00:33:46 +00:00
|
|
|
|
woocommerce_task_list_complete: true,
|
|
|
|
|
} );
|
|
|
|
|
}
|
2020-03-23 20:47:12 +00:00
|
|
|
|
|
|
|
|
|
this.possiblyTrackCompletedTasks();
|
2019-07-18 10:11:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-29 02:08:39 +00:00
|
|
|
|
componentDidUpdate( prevProps ) {
|
2020-03-23 20:47:12 +00:00
|
|
|
|
const { completedTaskKeys, incompleteTasks, query, updateOptions } = this.props;
|
|
|
|
|
const {
|
|
|
|
|
completedTaskKeys: prevCompletedTaskKeys,
|
|
|
|
|
incompleteTasks: prevIncompleteTasks,
|
|
|
|
|
query: prevQuery,
|
|
|
|
|
} = prevProps;
|
|
|
|
|
const { task: prevTask } = prevQuery;
|
|
|
|
|
const { task } = query;
|
2019-10-29 02:08:39 +00:00
|
|
|
|
|
|
|
|
|
if ( prevTask !== task ) {
|
2019-10-29 18:24:24 +00:00
|
|
|
|
window.document.documentElement.scrollTop = 0;
|
2019-10-29 02:08:39 +00:00
|
|
|
|
this.recordTaskView();
|
|
|
|
|
}
|
2020-03-23 20:47:12 +00:00
|
|
|
|
|
|
|
|
|
if ( ! incompleteTasks.length && prevIncompleteTasks.length ) {
|
|
|
|
|
updateOptions( {
|
|
|
|
|
woocommerce_task_list_complete: true,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( ! isEqual( prevCompletedTaskKeys, completedTaskKeys ) ) {
|
|
|
|
|
this.possiblyTrackCompletedTasks();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
possiblyTrackCompletedTasks() {
|
|
|
|
|
const { completedTaskKeys, trackedCompletedTasks, updateOptions } = this.props;
|
|
|
|
|
|
|
|
|
|
if ( ! isEqual( trackedCompletedTasks, completedTaskKeys ) ) {
|
|
|
|
|
updateOptions( {
|
|
|
|
|
woocommerce_task_list_tracked_completed_tasks: completedTaskKeys,
|
|
|
|
|
} );
|
|
|
|
|
}
|
2019-10-29 02:08:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 10:11:21 +00:00
|
|
|
|
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-12-31 08:50:45 +00:00
|
|
|
|
getTasks() {
|
|
|
|
|
const { profileItems, query, taskListPayments } = this.props;
|
|
|
|
|
|
|
|
|
|
return getAllTasks( {
|
|
|
|
|
profileItems,
|
|
|
|
|
options: taskListPayments,
|
2020-02-14 02:23:21 +00:00
|
|
|
|
query,
|
2019-12-31 08:50:45 +00:00
|
|
|
|
toggleCartModal: this.toggleCartModal.bind( this ),
|
2020-02-14 02:23:21 +00:00
|
|
|
|
} ).filter( ( task ) => task.visible );
|
2019-12-31 08:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-02 22:22:32 +00:00
|
|
|
|
getPluginsInformation() {
|
|
|
|
|
const { isJetpackConnected } = this.props;
|
|
|
|
|
const { activePlugins, installedPlugins } = getSetting(
|
|
|
|
|
'onboarding',
|
|
|
|
|
{}
|
|
|
|
|
);
|
|
|
|
|
return {
|
|
|
|
|
wcs_installed: installedPlugins.includes( 'woocommerce-services' ),
|
|
|
|
|
wcs_active: activePlugins.includes( 'woocommerce-services' ),
|
|
|
|
|
jetpack_installed: installedPlugins.includes( 'jetpack' ),
|
|
|
|
|
jetpack_active: activePlugins.includes( 'jetpack' ),
|
|
|
|
|
jetpack_connected: isJetpackConnected,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-29 02:08:39 +00:00
|
|
|
|
recordTaskView() {
|
|
|
|
|
const { task } = this.props.query;
|
2020-03-02 22:22:32 +00:00
|
|
|
|
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
|
|
|
const pluginsInformation = this.getPluginsInformation();
|
2019-10-29 02:08:39 +00:00
|
|
|
|
|
|
|
|
|
if ( ! task ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recordEvent( 'task_view', {
|
|
|
|
|
task_name: task,
|
2020-03-02 22:22:32 +00:00
|
|
|
|
...pluginsInformation,
|
2019-10-29 02:08:39 +00:00
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recordTaskListView() {
|
2019-10-07 20:27:34 +00:00
|
|
|
|
if ( this.getCurrentTask() ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-01-02 02:36:25 +00:00
|
|
|
|
|
2019-10-07 20:27:34 +00:00
|
|
|
|
const { profileItems } = this.props;
|
2019-12-31 08:50:45 +00:00
|
|
|
|
const tasks = this.getTasks();
|
2020-01-02 02:36:25 +00:00
|
|
|
|
|
2019-10-07 20:27:34 +00:00
|
|
|
|
recordEvent( 'tasklist_view', {
|
|
|
|
|
number_tasks: tasks.length,
|
|
|
|
|
store_connected: profileItems.wccom_connected,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
|
keepTaskCard() {
|
|
|
|
|
recordEvent( 'tasklist_completed', {
|
|
|
|
|
action: 'keep_card',
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_prompt_shown: true,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hideTaskCard( action ) {
|
|
|
|
|
recordEvent( 'tasklist_completed', {
|
|
|
|
|
action,
|
|
|
|
|
} );
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_hidden: 'yes',
|
|
|
|
|
woocommerce_task_list_prompt_shown: true,
|
|
|
|
|
} );
|
2019-08-01 18:09:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 02:54:38 +00:00
|
|
|
|
getCurrentTask() {
|
|
|
|
|
const { task } = this.props.query;
|
2020-02-14 02:23:21 +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-10-11 12:55:35 +00:00
|
|
|
|
renderPrompt() {
|
|
|
|
|
if ( this.props.promptShown ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Snackbar className="woocommerce-task-card__prompt">
|
2019-12-17 12:49:57 +00:00
|
|
|
|
<div className="woocommerce-task-card__prompt-pointer" />
|
|
|
|
|
<div className="woocommerce-task-card__prompt-content">
|
2020-02-14 02:23:21 +00:00
|
|
|
|
<span>
|
|
|
|
|
{ __( 'Is this card useful?', 'woocommerce-admin' ) }
|
|
|
|
|
</span>
|
2019-12-17 12:49:57 +00:00
|
|
|
|
<div className="woocommerce-task-card__prompt-actions">
|
2020-02-14 02:23:21 +00:00
|
|
|
|
<Button
|
|
|
|
|
isLink
|
|
|
|
|
onClick={ () => this.hideTaskCard( 'hide_card' ) }
|
|
|
|
|
>
|
2019-12-17 12:49:57 +00:00
|
|
|
|
{ __( 'No, hide it', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
<Button isLink onClick={ () => this.keepTaskCard() }>
|
|
|
|
|
{ __( 'Yes, keep it', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2019-10-11 12:55:35 +00:00
|
|
|
|
</div>
|
|
|
|
|
</Snackbar>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderMenu() {
|
|
|
|
|
return (
|
|
|
|
|
<EllipsisMenu
|
|
|
|
|
label={ __( 'Task List Options', 'woocommerce-admin' ) }
|
|
|
|
|
renderContent={ () => (
|
|
|
|
|
<div className="woocommerce-task-card__section-controls">
|
2020-02-14 02:23:21 +00:00
|
|
|
|
<MenuItem
|
|
|
|
|
isClickable
|
|
|
|
|
onInvoke={ () =>
|
|
|
|
|
this.hideTaskCard( 'remove_card' )
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
icon={ 'trash' }
|
|
|
|
|
label={ __( 'Remove block' ) }
|
|
|
|
|
/>
|
2019-10-11 12:55:35 +00:00
|
|
|
|
{ __( 'Remove this card', 'woocommerce-admin' ) }
|
|
|
|
|
</MenuItem>
|
|
|
|
|
</div>
|
|
|
|
|
) }
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-31 08:50:45 +00:00
|
|
|
|
toggleCartModal() {
|
2020-01-02 02:36:25 +00:00
|
|
|
|
const { isCartModalOpen } = this.state;
|
|
|
|
|
|
|
|
|
|
if ( ! isCartModalOpen ) {
|
|
|
|
|
recordEvent( 'tasklist_purchase_extensions' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState( { isCartModalOpen: ! isCartModalOpen } );
|
2019-12-31 08:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-01 04:00:57 +00:00
|
|
|
|
closeWelcomeModal() {
|
|
|
|
|
// Prevent firing this event before the modal is seen.
|
2020-02-14 02:23:21 +00:00
|
|
|
|
if (
|
|
|
|
|
document.body.classList.contains( 'woocommerce-admin-is-loading' )
|
|
|
|
|
) {
|
2019-11-01 04:00:57 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState( { isWelcomeModalOpen: false } );
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_welcome_modal_dismissed: true,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderWelcomeModal() {
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
title={
|
|
|
|
|
<Fragment>
|
|
|
|
|
<span
|
|
|
|
|
role="img"
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
focusable="false"
|
|
|
|
|
className="woocommerce-task-dashboard__welcome-modal-icon"
|
|
|
|
|
>
|
|
|
|
|
🚀
|
|
|
|
|
</span>
|
2020-02-14 02:23:21 +00:00
|
|
|
|
{ __(
|
|
|
|
|
"Woo hoo - you're almost there!",
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
2019-11-01 04:00:57 +00:00
|
|
|
|
</Fragment>
|
|
|
|
|
}
|
|
|
|
|
onRequestClose={ () => this.closeWelcomeModal() }
|
|
|
|
|
className="woocommerce-task-dashboard__welcome-modal"
|
|
|
|
|
>
|
|
|
|
|
<div className="woocommerce-task-dashboard__welcome-modal-wrapper">
|
|
|
|
|
<div className="woocommerce-task-dashboard__welcome-modal-message">
|
|
|
|
|
<p>
|
|
|
|
|
{ __(
|
|
|
|
|
'Based on the information you provided we’ve prepared some final set up tasks for you to perform.',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
{ __(
|
|
|
|
|
'Once complete your store will be ready for launch - exciting!',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2020-02-14 02:23:21 +00:00
|
|
|
|
<Button
|
|
|
|
|
isPrimary
|
|
|
|
|
isDefault
|
|
|
|
|
onClick={ () => this.closeWelcomeModal() }
|
|
|
|
|
>
|
2019-11-01 04:00:57 +00:00
|
|
|
|
{ __( 'Continue', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-13 04:34:53 +00:00
|
|
|
|
onSkipStoreSetup = () => {
|
|
|
|
|
const completedTaskKeys = this.getTasks()
|
|
|
|
|
.filter( ( x ) => x.completed )
|
|
|
|
|
.map( ( x ) => x.key );
|
|
|
|
|
|
2020-04-08 11:35:16 +00:00
|
|
|
|
recordEvent( 'tasklist_skip', {
|
2020-03-13 04:34:53 +00:00
|
|
|
|
completed_tasks_count: completedTaskKeys.length,
|
|
|
|
|
completed_tasks: completedTaskKeys,
|
|
|
|
|
reason: 'skip',
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_hidden: 'yes',
|
|
|
|
|
} );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onDoThisLater = () => {
|
|
|
|
|
const completedTaskKeys = this.getTasks()
|
|
|
|
|
.filter( ( x ) => x.completed )
|
|
|
|
|
.map( ( x ) => x.key );
|
|
|
|
|
|
2020-04-08 11:35:16 +00:00
|
|
|
|
recordEvent( 'tasklist_skip', {
|
2020-03-13 04:34:53 +00:00
|
|
|
|
completed_tasks_count: completedTaskKeys.length,
|
|
|
|
|
completed_tasks: completedTaskKeys,
|
|
|
|
|
reason: 'later',
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
this.props.updateOptions( {
|
|
|
|
|
woocommerce_task_list_do_this_later: true,
|
|
|
|
|
} );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
renderSkipActions() {
|
|
|
|
|
const { doThisLater } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="skip-actions">
|
|
|
|
|
<Button
|
|
|
|
|
isLink
|
|
|
|
|
className="is-secondary"
|
|
|
|
|
onClick={ this.onSkipStoreSetup }
|
|
|
|
|
>
|
|
|
|
|
{ __( 'Skip store setup', 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
{ ! doThisLater && ' | ' }
|
|
|
|
|
{ ! doThisLater && (
|
|
|
|
|
<Button
|
|
|
|
|
isLink
|
|
|
|
|
className="is-secondary"
|
|
|
|
|
onClick={ this.onDoThisLater }
|
|
|
|
|
>
|
|
|
|
|
{ __( "I'll do this later", 'woocommerce-admin' ) }
|
|
|
|
|
</Button>
|
|
|
|
|
) }
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-28 06:09:44 +00:00
|
|
|
|
render() {
|
2020-03-15 21:45:19 +00:00
|
|
|
|
const { inline, query } = this.props;
|
2019-12-31 08:50:45 +00:00
|
|
|
|
const { isCartModalOpen, isWelcomeModalOpen } = this.state;
|
2019-07-19 02:54:38 +00:00
|
|
|
|
const currentTask = this.getCurrentTask();
|
2020-02-14 02:23:21 +00:00
|
|
|
|
const listTasks = this.getTasks().map( ( task ) => {
|
|
|
|
|
task.className = classNames(
|
|
|
|
|
task.completed ? 'is-complete' : null,
|
|
|
|
|
task.className
|
|
|
|
|
);
|
2019-10-11 12:55:35 +00:00
|
|
|
|
task.before = task.completed ? (
|
|
|
|
|
<i className="material-icons-outlined">check_circle</i>
|
|
|
|
|
) : (
|
|
|
|
|
<i className="material-icons-outlined">{ task.icon }</i>
|
|
|
|
|
);
|
2020-02-14 02:23:21 +00:00
|
|
|
|
task.after = (
|
|
|
|
|
<i className="material-icons-outlined">chevron_right</i>
|
|
|
|
|
);
|
2019-10-29 18:03:07 +00:00
|
|
|
|
|
|
|
|
|
if ( ! task.onClick ) {
|
|
|
|
|
task.onClick = () => updateQueryString( { task: task.key } );
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
|
return task;
|
|
|
|
|
} );
|
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 ? (
|
2020-03-15 21:45:19 +00:00
|
|
|
|
cloneElement( currentTask.container, {
|
|
|
|
|
query,
|
|
|
|
|
} )
|
2019-07-19 02:54:38 +00:00
|
|
|
|
) : (
|
2019-10-11 12:55:35 +00:00
|
|
|
|
<Fragment>
|
|
|
|
|
<Card
|
|
|
|
|
className="woocommerce-task-card"
|
2020-02-14 02:23:21 +00:00
|
|
|
|
title={ __(
|
|
|
|
|
'Set up your store and start selling',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
2019-10-11 12:55:35 +00:00
|
|
|
|
description={ __(
|
|
|
|
|
'Below you’ll find a list of the most important steps to get your store up and running.',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
) }
|
2019-11-01 04:00:57 +00:00
|
|
|
|
menu={ inline && this.renderMenu() }
|
2019-10-11 12:55:35 +00:00
|
|
|
|
>
|
2019-11-01 04:00:57 +00:00
|
|
|
|
<List items={ listTasks } />
|
2019-10-11 12:55:35 +00:00
|
|
|
|
</Card>
|
2019-11-01 04:00:57 +00:00
|
|
|
|
{ inline && this.renderPrompt() }
|
|
|
|
|
{ isWelcomeModalOpen && this.renderWelcomeModal() }
|
2020-03-13 04:34:53 +00:00
|
|
|
|
{ this.renderSkipActions() }
|
2019-10-11 12:55:35 +00:00
|
|
|
|
</Fragment>
|
2019-07-19 02:54:38 +00:00
|
|
|
|
) }
|
2019-03-28 06:09:44 +00:00
|
|
|
|
</div>
|
2019-12-31 08:50:45 +00:00
|
|
|
|
{ isCartModalOpen && (
|
|
|
|
|
<CartModal
|
|
|
|
|
onClose={ () => this.toggleCartModal() }
|
|
|
|
|
onClickPurchaseLater={ () => this.toggleCartModal() }
|
|
|
|
|
/>
|
|
|
|
|
) }
|
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(
|
2020-03-23 20:47:12 +00:00
|
|
|
|
withSelect( ( select, props ) => {
|
2020-03-02 22:22:32 +00:00
|
|
|
|
const { getProfileItems, getOptions, isJetpackConnected } = select(
|
|
|
|
|
'wc-api'
|
|
|
|
|
);
|
2019-08-01 18:09:08 +00:00
|
|
|
|
const profileItems = getProfileItems();
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
2019-11-01 04:00:57 +00:00
|
|
|
|
const options = getOptions( [
|
|
|
|
|
'woocommerce_task_list_prompt_shown',
|
|
|
|
|
'woocommerce_task_list_welcome_modal_dismissed',
|
2020-03-13 04:34:53 +00:00
|
|
|
|
'woocommerce_task_list_hidden',
|
|
|
|
|
'woocommerce_task_list_do_this_later',
|
2020-03-23 20:47:12 +00:00
|
|
|
|
'woocommerce_task_list_tracked_completed_tasks',
|
2019-11-01 04:00:57 +00:00
|
|
|
|
] );
|
2020-02-14 02:23:21 +00:00
|
|
|
|
const promptShown = get(
|
|
|
|
|
options,
|
|
|
|
|
[ 'woocommerce_task_list_prompt_shown' ],
|
|
|
|
|
false
|
|
|
|
|
);
|
2019-11-01 04:00:57 +00:00
|
|
|
|
const modalDismissed = get(
|
|
|
|
|
options,
|
|
|
|
|
[ 'woocommerce_task_list_welcome_modal_dismissed' ],
|
2019-10-03 16:03:29 +00:00
|
|
|
|
false
|
|
|
|
|
);
|
2020-02-14 02:23:21 +00:00
|
|
|
|
const taskListPayments = getOptions( [
|
|
|
|
|
'woocommerce_task_list_payments',
|
|
|
|
|
] );
|
2020-03-13 04:34:53 +00:00
|
|
|
|
const doThisLater = get(
|
|
|
|
|
options,
|
|
|
|
|
[ 'woocommerce_task_list_do_this_later' ],
|
|
|
|
|
false
|
|
|
|
|
);
|
2020-03-23 20:47:12 +00:00
|
|
|
|
const trackedCompletedTasks = get(
|
|
|
|
|
options,
|
|
|
|
|
[ 'woocommerce_task_list_tracked_completed_tasks' ],
|
|
|
|
|
[]
|
|
|
|
|
);
|
|
|
|
|
const tasks = getAllTasks( {
|
|
|
|
|
profileItems,
|
|
|
|
|
options: getOptions( [ 'woocommerce_task_list_payments' ] ),
|
|
|
|
|
query: props.query,
|
|
|
|
|
} );
|
|
|
|
|
const completedTaskKeys = tasks.filter( task => task.completed ).map( task => task.key );
|
|
|
|
|
const incompleteTasks = tasks.filter(
|
|
|
|
|
( task ) => task.visible && ! task.completed
|
|
|
|
|
);
|
2019-10-11 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
return {
|
2019-11-01 04:00:57 +00:00
|
|
|
|
modalDismissed,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
profileItems,
|
|
|
|
|
promptShown,
|
2019-12-31 08:50:45 +00:00
|
|
|
|
taskListPayments,
|
2020-03-02 22:22:32 +00:00
|
|
|
|
isJetpackConnected: isJetpackConnected(),
|
2020-03-13 04:34:53 +00:00
|
|
|
|
doThisLater,
|
2020-03-23 20:47:12 +00:00
|
|
|
|
incompleteTasks,
|
|
|
|
|
trackedCompletedTasks,
|
|
|
|
|
completedTaskKeys,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
};
|
|
|
|
|
} ),
|
2020-02-14 02:23:21 +00:00
|
|
|
|
withDispatch( ( dispatch ) => {
|
2019-10-11 12:55:35 +00:00
|
|
|
|
const { updateOptions } = dispatch( 'wc-api' );
|
|
|
|
|
return {
|
|
|
|
|
updateOptions,
|
|
|
|
|
};
|
2019-08-01 18:09:08 +00:00
|
|
|
|
} )
|
|
|
|
|
)( TaskDashboard );
|