Use numberFormat() to format all non-currency numbers in tables (https://github.com/woocommerce/woocommerce-admin/pull/913)

This commit is contained in:
Albert Juhé Lluveras 2018-11-25 21:31:38 -06:00 committed by GitHub
parent e4f05f31cb
commit 0acc43a551
5 changed files with 22 additions and 17 deletions

View File

@ -22,6 +22,7 @@ import { onQueryChange } from '@woocommerce/navigation';
*/ */
import ReportError from 'analytics/components/report-error'; import ReportError from 'analytics/components/report-error';
import { getReportChartData, getReportTableData } from 'store/reports/utils'; import { getReportChartData, getReportTableData } from 'store/reports/utils';
import { numberFormat } from 'lib/number';
class CouponsReportTable extends Component { class CouponsReportTable extends Component {
getHeadersContent() { getHeadersContent() {
@ -86,7 +87,7 @@ class CouponsReportTable extends Component {
href={ '/analytics/orders?filter=advanced&code_includes=' + coupon_id } href={ '/analytics/orders?filter=advanced&code_includes=' + coupon_id }
type="wc-admin" type="wc-admin"
> >
{ orders_count } { numberFormat( orders_count ) }
</Link> </Link>
); );
@ -130,11 +131,11 @@ class CouponsReportTable extends Component {
return [ return [
{ {
label: _n( 'coupon', 'coupons', totals.coupons_count, 'wc-admin' ), label: _n( 'coupon', 'coupons', totals.coupons_count, 'wc-admin' ),
value: totals.coupons_count, value: numberFormat( totals.coupons_count ),
}, },
{ {
label: _n( 'order', 'orders', totals.orders_count, 'wc-admin' ), label: _n( 'order', 'orders', totals.orders_count, 'wc-admin' ),
value: totals.orders_count, value: numberFormat( totals.orders_count ),
}, },
{ {
label: __( 'gross discounted', 'wc-admin' ), label: __( 'gross discounted', 'wc-admin' ),

View File

@ -28,6 +28,7 @@ import { getAdminLink, onQueryChange } from '@woocommerce/navigation';
import ReportError from 'analytics/components/report-error'; import ReportError from 'analytics/components/report-error';
import { QUERY_DEFAULTS } from 'store/constants'; import { QUERY_DEFAULTS } from 'store/constants';
import { getReportChartData, getFilterQuery } from 'store/reports/utils'; import { getReportChartData, getFilterQuery } from 'store/reports/utils';
import { numberFormat } from 'lib/number';
import './style.scss'; import './style.scss';
class OrdersReportTable extends Component { class OrdersReportTable extends Component {
@ -184,7 +185,7 @@ class OrdersReportTable extends Component {
value: products.map( product => product.label ).join( ' ' ), value: products.map( product => product.label ).join( ' ' ),
}, },
{ {
display: items_sold, display: numberFormat( items_sold ),
value: items_sold, value: items_sold,
}, },
{ {
@ -206,11 +207,11 @@ class OrdersReportTable extends Component {
return [ return [
{ {
label: _n( 'order', 'orders', totals.num_items_sold, 'wc-admin' ), label: _n( 'order', 'orders', totals.num_items_sold, 'wc-admin' ),
value: totals.orders_count, value: numberFormat( totals.orders_count ),
}, },
{ {
label: _n( 'new customer', 'new customers', totals.num_new_customers, 'wc-admin' ), label: _n( 'new customer', 'new customers', totals.num_new_customers, 'wc-admin' ),
value: totals.num_new_customers, value: numberFormat( totals.num_new_customers ),
}, },
{ {
label: _n( label: _n(
@ -219,19 +220,19 @@ class OrdersReportTable extends Component {
totals.num_returning_customers, totals.num_returning_customers,
'wc-admin' 'wc-admin'
), ),
value: totals.num_returning_customers, value: numberFormat( totals.num_returning_customers ),
}, },
{ {
label: _n( 'product', 'products', totals.products, 'wc-admin' ), label: _n( 'product', 'products', totals.products, 'wc-admin' ),
value: totals.products, value: numberFormat( totals.products ),
}, },
{ {
label: _n( 'item sold', 'items sold', totals.num_items_sold, 'wc-admin' ), label: _n( 'item sold', 'items sold', totals.num_items_sold, 'wc-admin' ),
value: totals.num_items_sold, value: numberFormat( totals.num_items_sold ),
}, },
{ {
label: _n( 'coupon', 'coupons', totals.coupons, 'wc-admin' ), label: _n( 'coupon', 'coupons', totals.coupons, 'wc-admin' ),
value: totals.coupons, value: numberFormat( totals.coupons ),
}, },
{ {
label: __( 'net revenue', 'wc-admin' ), label: __( 'net revenue', 'wc-admin' ),

View File

@ -20,6 +20,7 @@ import { getNewPath, getPersistedQuery, onQueryChange } from '@woocommerce/navig
*/ */
import ReportError from 'analytics/components/report-error'; import ReportError from 'analytics/components/report-error';
import { getReportChartData, getReportTableData } from 'store/reports/utils'; import { getReportChartData, getReportTableData } from 'store/reports/utils';
import { numberFormat } from 'lib/number';
class ProductsReportTable extends Component { class ProductsReportTable extends Component {
getHeadersContent() { getHeadersContent() {
@ -117,7 +118,7 @@ class ProductsReportTable extends Component {
value: sku, value: sku,
}, },
{ {
display: items_sold, display: numberFormat( items_sold ),
value: items_sold, value: items_sold,
}, },
{ {
@ -139,7 +140,7 @@ class ProductsReportTable extends Component {
value: Array.isArray( categories ) ? categories.map( cat => cat.name ).join( ', ' ) : '', value: Array.isArray( categories ) ? categories.map( cat => cat.name ).join( ', ' ) : '',
}, },
{ {
display: variations.length, display: numberFormat( variations.length ),
value: variations.length, value: variations.length,
}, },
{ {
@ -151,7 +152,7 @@ class ProductsReportTable extends Component {
value: stockStatuses[ stock_status ], value: stockStatuses[ stock_status ],
}, },
{ {
display: stock_quantity, display: numberFormat( stock_quantity ),
value: stock_quantity, value: stock_quantity,
}, },
]; ];

View File

@ -27,6 +27,7 @@ import { onQueryChange } from '@woocommerce/navigation';
*/ */
import ReportError from 'analytics/components/report-error'; import ReportError from 'analytics/components/report-error';
import { QUERY_DEFAULTS } from 'store/constants'; import { QUERY_DEFAULTS } from 'store/constants';
import { numberFormat } from 'lib/number';
class RevenueReportTable extends Component { class RevenueReportTable extends Component {
getHeadersContent() { getHeadersContent() {
@ -114,7 +115,7 @@ class RevenueReportTable extends Component {
href={ 'edit.php?post_type=shop_order&m=' + formatDate( 'Ymd', row.date_start ) } href={ 'edit.php?post_type=shop_order&m=' + formatDate( 'Ymd', row.date_start ) }
type="wp-admin" type="wp-admin"
> >
{ orders_count } { numberFormat( orders_count ) }
</Link> </Link>
); );
return [ return [

View File

@ -20,6 +20,7 @@ import { onQueryChange } from '@woocommerce/navigation';
*/ */
import ReportError from 'analytics/components/report-error'; import ReportError from 'analytics/components/report-error';
import { getReportChartData, getReportTableData } from 'store/reports/utils'; import { getReportChartData, getReportTableData } from 'store/reports/utils';
import { numberFormat } from 'lib/number';
class TaxesReportTable extends Component { class TaxesReportTable extends Component {
getHeadersContent() { getHeadersContent() {
@ -99,7 +100,7 @@ class TaxesReportTable extends Component {
value: getCurrencyFormatDecimal( shipping_tax ), value: getCurrencyFormatDecimal( shipping_tax ),
}, },
{ {
display: orders_count, display: numberFormat( orders_count ),
value: orders_count, value: orders_count,
}, },
]; ];
@ -115,7 +116,7 @@ class TaxesReportTable extends Component {
return [ return [
{ {
label: _n( 'tax code', 'tax codes', totalRows, 'wc-admin' ), label: _n( 'tax code', 'tax codes', totalRows, 'wc-admin' ),
value: totalRows, value: numberFormat( totalRows ),
}, },
{ {
label: __( 'total tax', 'wc-admin' ), label: __( 'total tax', 'wc-admin' ),
@ -131,7 +132,7 @@ class TaxesReportTable extends Component {
}, },
{ {
label: _n( 'order', 'orders', totals.orders_count, 'wc-admin' ), label: _n( 'order', 'orders', totals.orders_count, 'wc-admin' ),
value: totals.orders_count, value: numberFormat( totals.orders_count ),
}, },
]; ];
} }