2018-05-03 18:23:17 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2018-06-29 18:27:18 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2018-08-01 19:07:17 +00:00
|
|
|
import { ToggleControl } from '@wordpress/components';
|
2018-07-23 20:14:40 +00:00
|
|
|
import { Component } from '@wordpress/element';
|
2018-05-03 18:23:17 +00:00
|
|
|
|
2018-05-10 19:23:41 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-08-20 21:18:13 +00:00
|
|
|
import {
|
|
|
|
Card,
|
|
|
|
EllipsisMenu,
|
|
|
|
MenuItem,
|
|
|
|
MenuTitle,
|
|
|
|
SummaryList,
|
|
|
|
SummaryNumber,
|
|
|
|
} from '@woocommerce/components';
|
2018-06-29 18:27:18 +00:00
|
|
|
import './style.scss';
|
2018-05-10 19:23:41 +00:00
|
|
|
|
2018-07-02 18:08:50 +00:00
|
|
|
class StorePerformance extends Component {
|
2018-05-14 15:47:42 +00:00
|
|
|
constructor() {
|
|
|
|
super( ...arguments );
|
|
|
|
this.state = {
|
|
|
|
showCustomers: true,
|
|
|
|
showProducts: true,
|
|
|
|
showOrders: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.toggle = this.toggle.bind( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
toggle( type ) {
|
|
|
|
return () => {
|
|
|
|
this.setState( state => ( { [ type ]: ! state[ type ] } ) );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
renderMenu() {
|
|
|
|
return (
|
2018-07-10 12:48:06 +00:00
|
|
|
<EllipsisMenu label={ __( 'Choose which analytics to display', 'wc-admin' ) }>
|
|
|
|
<MenuTitle>{ __( 'Display Stats:', 'wc-admin' ) }</MenuTitle>
|
2018-05-14 15:47:42 +00:00
|
|
|
<MenuItem onInvoke={ this.toggle( 'showCustomers' ) }>
|
|
|
|
<ToggleControl
|
2018-07-10 12:48:06 +00:00
|
|
|
label={ __( 'Show Customers', 'wc-admin' ) }
|
2018-05-14 15:47:42 +00:00
|
|
|
checked={ this.state.showCustomers }
|
|
|
|
onChange={ this.toggle( 'showCustomers' ) }
|
|
|
|
/>
|
|
|
|
</MenuItem>
|
|
|
|
<MenuItem onInvoke={ this.toggle( 'showProducts' ) }>
|
|
|
|
<ToggleControl
|
2018-07-10 12:48:06 +00:00
|
|
|
label={ __( 'Show Products', 'wc-admin' ) }
|
2018-05-14 15:47:42 +00:00
|
|
|
checked={ this.state.showProducts }
|
|
|
|
onChange={ this.toggle( 'showProducts' ) }
|
|
|
|
/>
|
|
|
|
</MenuItem>
|
|
|
|
<MenuItem onInvoke={ this.toggle( 'showOrders' ) }>
|
|
|
|
<ToggleControl
|
2018-07-10 12:48:06 +00:00
|
|
|
label={ __( 'Show Orders', 'wc-admin' ) }
|
2018-05-14 15:47:42 +00:00
|
|
|
checked={ this.state.showOrders }
|
|
|
|
onChange={ this.toggle( 'showOrders' ) }
|
|
|
|
/>
|
|
|
|
</MenuItem>
|
|
|
|
</EllipsisMenu>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-05-03 18:23:17 +00:00
|
|
|
render() {
|
2018-08-01 19:07:17 +00:00
|
|
|
const totalOrders = 10;
|
|
|
|
const totalProducts = 1000;
|
2018-05-14 15:47:42 +00:00
|
|
|
const { showCustomers, showProducts, showOrders } = this.state;
|
|
|
|
|
2018-05-03 18:23:17 +00:00
|
|
|
return (
|
2018-06-29 18:27:18 +00:00
|
|
|
<Card
|
2018-07-10 12:48:06 +00:00
|
|
|
title={ __( 'Store Performance', 'wc-admin' ) }
|
2018-06-29 18:27:18 +00:00
|
|
|
menu={ this.renderMenu() }
|
|
|
|
className="woocommerce-dashboard__store-performance"
|
|
|
|
>
|
|
|
|
<SummaryList>
|
2018-05-14 15:47:42 +00:00
|
|
|
{ showCustomers && (
|
2018-07-30 15:14:09 +00:00
|
|
|
<SummaryNumber
|
|
|
|
label={ __( 'New Customers', 'wc-admin' ) }
|
|
|
|
value={ '2' }
|
|
|
|
prevLabel={ __( 'Previous Week:', 'wc-admin' ) }
|
|
|
|
prevValue={ 3 }
|
|
|
|
delta={ -33 }
|
|
|
|
/>
|
2018-05-14 15:47:42 +00:00
|
|
|
) }
|
|
|
|
{ showProducts && (
|
2018-07-30 15:14:09 +00:00
|
|
|
<SummaryNumber
|
|
|
|
label={ __( 'Total Products', 'wc-admin' ) }
|
|
|
|
value={ totalProducts }
|
|
|
|
prevLabel={ __( 'Previous Week:', 'wc-admin' ) }
|
|
|
|
prevValue={ totalProducts }
|
|
|
|
delta={ 0 }
|
|
|
|
/>
|
2018-06-29 18:27:18 +00:00
|
|
|
) }
|
|
|
|
{ showOrders && (
|
|
|
|
<SummaryNumber
|
2018-07-10 12:48:06 +00:00
|
|
|
label={ __( 'Total Orders', 'wc-admin' ) }
|
2018-07-30 15:14:09 +00:00
|
|
|
value={ totalOrders }
|
|
|
|
prevLabel={ __( 'Previous Week:', 'wc-admin' ) }
|
|
|
|
prevValue={ totalOrders }
|
|
|
|
delta={ 0 }
|
2018-06-29 18:27:18 +00:00
|
|
|
/>
|
2018-05-14 15:47:42 +00:00
|
|
|
) }
|
2018-06-29 18:27:18 +00:00
|
|
|
</SummaryList>
|
2018-05-10 19:23:41 +00:00
|
|
|
</Card>
|
2018-05-03 18:23:17 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-01 19:07:17 +00:00
|
|
|
export default StorePerformance;
|