/** @format */
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { ToggleControl, withAPIData } from '@wordpress/components';
import { Component } from '@wordpress/element';
import { compose } from '@wordpress/compose';
/**
* Internal dependencies
*/
import Card from 'components/card';
import { EllipsisMenu, MenuItem, MenuTitle } from 'components/ellipsis-menu';
import { SummaryList, SummaryNumber } from 'components/summary';
import './style.scss';
class StorePerformance extends Component {
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 (
{ __( 'Display Stats:', 'wc-admin' ) }
);
}
render() {
const { orders, products } = this.props;
const totalOrders = ( orders.data && orders.data.length ) || 0;
const totalProducts = ( products.data && products.data.length ) || 0;
const { showCustomers, showProducts, showOrders } = this.state;
return (
{ showCustomers && (
) }
{ showProducts && (
) }
{ showOrders && (
) }
);
}
}
export default compose( [
withAPIData( () => ( {
orders: '/wc/v2/orders?status=processing',
products: '/wc/v2/products',
} ) ),
] )( StorePerformance );