@nuskin/ns-product-lib 1.4.4 → 1.4.5-cx12-4643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/product.js +1 -1
- package/src/productStatusMapper.js +9 -8
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [1.4.5-cx12-4643.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.4...v1.4.5-cx12-4643.1) (2022-07-27)
|
2
|
+
|
3
|
+
|
4
|
+
### Fix
|
5
|
+
|
6
|
+
* Check for valid productStatusV2Response before reading items (#CX12-4643) ([40cb2a7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/40cb2a770e76c68da33d7322d2947323696d3781)), closes [#CX12-4643](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX12-4643)
|
7
|
+
* sonarQube issue ([82deb06](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/82deb06c84af639829394da786184031a07f4da5))
|
8
|
+
|
1
9
|
## [1.4.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.3...v1.4.4) (2022-06-10)
|
2
10
|
|
3
11
|
|
package/package.json
CHANGED
package/src/product.js
CHANGED
@@ -308,7 +308,7 @@ const Product = function(productData) {
|
|
308
308
|
}
|
309
309
|
if (productStatus.csv) {
|
310
310
|
Object.keys(productStatus.csv).map((csvKey) => {
|
311
|
-
this.addCvWithType(csvKey, productStatus.csv[csvKey]);
|
311
|
+
return this.addCvWithType(csvKey, productStatus.csv[csvKey]);
|
312
312
|
}, this);
|
313
313
|
}
|
314
314
|
this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
|
@@ -13,7 +13,7 @@ const ProductStatusMapper = {
|
|
13
13
|
*/
|
14
14
|
createProductStatusesFromV2: function(productStatusV2Response) {
|
15
15
|
const productStatuses = [];
|
16
|
-
if (productStatusV2Response.items) {
|
16
|
+
if (productStatusV2Response && productStatusV2Response.items) {
|
17
17
|
for (const productStatusSku of Object.keys(productStatusV2Response.items)) {
|
18
18
|
const productStatusV2 = productStatusV2Response.items[productStatusSku];
|
19
19
|
productStatusV2.sku = productStatusSku;
|
@@ -55,11 +55,12 @@ const ProductStatusMapper = {
|
|
55
55
|
* @return {String}
|
56
56
|
*/
|
57
57
|
function getStatusPartFromV2(productStatusV2) {
|
58
|
-
const
|
58
|
+
const status = productStatusV2.status || {};
|
59
|
+
const retailStatusIsReleased = status.retail === 'RELEASED_FOR_SALE';
|
59
60
|
const wholesaleStatusIsReleased =
|
60
|
-
|
61
|
-
const retailNotSet =
|
62
|
-
const wholesaleNotSet =
|
61
|
+
status.wholesale === 'RELEASED_FOR_SALE';
|
62
|
+
const retailNotSet = status.retail === 'NOT_SET_FOR_DIST_TYPE';
|
63
|
+
const wholesaleNotSet = status.wholesale === 'NOT_SET_FOR_DIST_TYPE';
|
63
64
|
if (retailStatusIsReleased || wholesaleStatusIsReleased) {
|
64
65
|
return 'RELEASED_FOR_SALE';
|
65
66
|
}
|
@@ -69,14 +70,14 @@ function getStatusPartFromV2(productStatusV2) {
|
|
69
70
|
return 'NOT_RELEASED_FOR_SALE';
|
70
71
|
}
|
71
72
|
if (retailNotSet) {
|
72
|
-
return
|
73
|
+
return status.wholesale;
|
73
74
|
}
|
74
75
|
if (wholesaleNotSet) {
|
75
|
-
return
|
76
|
+
return status.retail;
|
76
77
|
}
|
77
78
|
}
|
78
79
|
|
79
|
-
return
|
80
|
+
return status.retail;
|
80
81
|
}
|
81
82
|
|
82
83
|
/**
|