Fix null values in CSV columns export (https://github.com/woocommerce/woocommerce-admin/pull/1652)
* Fix null values in CSV columns export * Check if value is null or undefined to avoid falsey for 0 values * Add null value to CSV tests * Improve changelog message
This commit is contained in:
parent
9c95a62f3b
commit
88c2973e2a
|
@ -2,4 +2,4 @@
|
|||
|
||||
export default `Date,Orders,Gross Revenue,Refunds,Taxes,Shipping,Net Revenue
|
||||
2018-10-01 00:00:00,1,411,0,0,0,411
|
||||
2018-10-02 00:00:00,0,0,0,0,0,0`;
|
||||
2018-10-02 00:00:00,0,0,,0,0,0`;
|
||||
|
|
|
@ -50,7 +50,7 @@ export default [
|
|||
},
|
||||
{
|
||||
display: '€0.00',
|
||||
value: 0,
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
display: '€0.00',
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# 1.1.0
|
||||
|
||||
- Fix error in `getCSVRows` when there is a null or undefined column value
|
||||
|
||||
# 1.0.0
|
||||
|
||||
- Released package
|
||||
|
|
|
@ -13,7 +13,9 @@ function getCSVRows( rows ) {
|
|||
return Array.isArray( rows )
|
||||
? rows
|
||||
.map( row =>
|
||||
row.map( rowItem => rowItem.value.toString().replace( /,/g, '' ) ).join( ',' )
|
||||
row.map( rowItem =>
|
||||
rowItem.value !== undefined && rowItem.value !== null ? rowItem.value.toString().replace( /,/g, ''
|
||||
) : '' ).join( ',' )
|
||||
)
|
||||
.join( '\n' )
|
||||
: [];
|
||||
|
|
Loading…
Reference in New Issue