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:
parent
98289b32c9
commit
e1fd72d06b
|
@ -51,7 +51,8 @@ class ReportTable extends Component {
|
||||||
const ids = itemIdField ? orderedItems.map( item => item[ itemIdField ] ) : null;
|
const ids = itemIdField ? orderedItems.map( item => item[ itemIdField ] ) : null;
|
||||||
const rows = getRowsContent( orderedItems );
|
const rows = getRowsContent( orderedItems );
|
||||||
const totals = get( primaryData, [ 'data', 'totals' ], null );
|
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 (
|
return (
|
||||||
<TableCard
|
<TableCard
|
||||||
|
@ -63,7 +64,7 @@ class ReportTable extends Component {
|
||||||
rows={ rows }
|
rows={ rows }
|
||||||
rowsPerPage={ parseInt( query.per_page ) }
|
rowsPerPage={ parseInt( query.per_page ) }
|
||||||
summary={ summary }
|
summary={ summary }
|
||||||
totalRows={ items.totalCount || 0 }
|
totalRows={ totalCount }
|
||||||
{ ...tableProps }
|
{ ...tableProps }
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -98,14 +98,15 @@ export default class CategoriesReportTable extends Component {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
getSummary( totals ) {
|
getSummary( totals, totalCount ) {
|
||||||
if ( ! totals ) {
|
if ( ! totals ) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: _n( 'category', 'categories', totals.categories_count, 'wc-admin' ),
|
label: _n( 'category', 'categories', totalCount, 'wc-admin' ),
|
||||||
value: numberFormat( totals.categories_count ),
|
value: numberFormat( totalCount ),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _n( 'item sold', 'items sold', totals.items_sold, 'wc-admin' ),
|
label: _n( 'item sold', 'items sold', totals.items_sold, 'wc-admin' ),
|
||||||
|
|
|
@ -162,18 +162,15 @@ class RevenueReportTable extends Component {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
getSummary( totals ) {
|
getSummary( totals, totalCount ) {
|
||||||
if ( ! totals ) {
|
if ( ! totals ) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const { tableData } = this.props;
|
|
||||||
const daysCount = tableData.items.totalCount;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: _n( 'day', 'days', daysCount, 'wc-admin' ),
|
label: _n( 'day', 'days', totalCount, 'wc-admin' ),
|
||||||
value: numberFormat( daysCount ),
|
value: numberFormat( totalCount ),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _n( 'order', 'orders', totals.orders_count, 'wc-admin' ),
|
label: _n( 'order', 'orders', totals.orders_count, 'wc-admin' ),
|
||||||
|
|
Loading…
Reference in New Issue