Fix 'categories' value in Categories report table summary (https://github.com/woocommerce/woocommerce-admin/pull/995)

* Add table summary to Revenue report

* Fix 'categories' value in Categories report table summary
This commit is contained in:
Albert Juhé Lluveras 2018-12-04 13:29:58 -06:00 committed by GitHub
parent 98289b32c9
commit e1fd72d06b
3 changed files with 10 additions and 11 deletions

View File

@ -51,7 +51,8 @@ class ReportTable extends Component {
const ids = itemIdField ? orderedItems.map( item => item[ itemIdField ] ) : null;
const rows = getRowsContent( orderedItems );
const totals = get( primaryData, [ 'data', 'totals' ], null );
const summary = getSummary ? getSummary( totals ) : null;
const totalCount = items.totalCount || 0;
const summary = getSummary ? getSummary( totals, totalCount ) : null;
return (
<TableCard
@ -63,7 +64,7 @@ class ReportTable extends Component {
rows={ rows }
rowsPerPage={ parseInt( query.per_page ) }
summary={ summary }
totalRows={ items.totalCount || 0 }
totalRows={ totalCount }
{ ...tableProps }
/>
);

View File

@ -98,14 +98,15 @@ export default class CategoriesReportTable extends Component {
} );
}
getSummary( totals ) {
getSummary( totals, totalCount ) {
if ( ! totals ) {
return [];
}
return [
{
label: _n( 'category', 'categories', totals.categories_count, 'wc-admin' ),
value: numberFormat( totals.categories_count ),
label: _n( 'category', 'categories', totalCount, 'wc-admin' ),
value: numberFormat( totalCount ),
},
{
label: _n( 'item sold', 'items sold', totals.items_sold, 'wc-admin' ),

View File

@ -162,18 +162,15 @@ class RevenueReportTable extends Component {
} );
}
getSummary( totals ) {
getSummary( totals, totalCount ) {
if ( ! totals ) {
return [];
}
const { tableData } = this.props;
const daysCount = tableData.items.totalCount;
return [
{
label: _n( 'day', 'days', daysCount, 'wc-admin' ),
value: numberFormat( daysCount ),
label: _n( 'day', 'days', totalCount, 'wc-admin' ),
value: numberFormat( totalCount ),
},
{
label: _n( 'order', 'orders', totals.orders_count, 'wc-admin' ),