@nuskin/ns-product-lib 1.3.6 → 1.4.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 CHANGED
@@ -1,3 +1,26 @@
1
+ ## [1.4.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.4.0...v1.4.1) (2022-03-31)
2
+
3
+
4
+ ### Fix
5
+
6
+ * adding locallyProduced flag to mapper (#CX16-5842) ([b5a31ca](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b5a31cab7cbaaba51af23f29bd70d8b0b495af44)), closes [#CX16-5842](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX16-5842)
7
+ * adding locallyProduced flag to mapper (#CX16-5842) ([c50407d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/c50407d90270e017a37d3427e43752da34002c11)), closes [#CX16-5842](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX16-5842)
8
+
9
+ # [1.4.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.3.7...v1.4.0) (2022-03-31)
10
+
11
+
12
+ ### Update
13
+
14
+ * adding locallyProduced flag (#CX16-5842) ([9213365](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/92133654db85e4af7f46a2223a5d999f75dbc9a5)), closes [#CX16-5842](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX16-5842)
15
+ * adding locallyProduced flag (#CX16-5842) ([7e303af](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7e303af1f14fd870ef571376e1960eb40fb7bd12)), closes [#CX16-5842](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX16-5842)
16
+
17
+ ## [1.3.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.3.6...v1.3.7) (2021-09-17)
18
+
19
+
20
+ ### Fix
21
+
22
+ * fixed issue of new order types coming in as true when set to [secure] (#CX12-4252) ([ab1d15e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ab1d15ec9591ad98b113bb0ce8817c1c1c2c03f0)), closes [#CX12-4252](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX12-4252)
23
+
1
24
  ## [1.3.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.3.5...v1.3.6) (2021-05-18)
2
25
 
3
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "1.3.6",
3
+ "version": "1.4.1",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/product.js CHANGED
@@ -17,6 +17,7 @@ const Product = function(productData) {
17
17
  this.custTypes = [];
18
18
  this.addOns = [];
19
19
  this.productCarouselImages = [];
20
+ this.locallyProduced = false;
20
21
 
21
22
  //class variables to be used instead of getters/setters
22
23
  this.globalProductID = "";
@@ -349,7 +350,7 @@ const Product = function(productData) {
349
350
  }
350
351
  return retVal;
351
352
  };
352
-
353
+
353
354
  this.getEventPriceTypes = () => {
354
355
  const eventPriceTypes = [];
355
356
 
@@ -490,6 +491,7 @@ const Product = function(productData) {
490
491
  retData.custTypes = this.custTypes;
491
492
  retData.division = this.division;
492
493
  retData.backOrderDate = this.backOrderDate;
494
+ retData.locallyProduced = this.locallyProduced;
493
495
  retData.agelocme = this.agelocme ? this.agelocme.toJSON() : null;
494
496
  retData.count = this.count;
495
497
  retData.flavor = this.flavor;
@@ -597,6 +599,7 @@ const Product = function(productData) {
597
599
  if (data.priceType) {
598
600
  this.priceType = data.priceType;
599
601
  }
602
+ this.locallyProduced = data.locallyProduced;
600
603
  this.count = productData.count;
601
604
  this.flavor = productData.flavor;
602
605
  this.size = productData.size;
@@ -36,6 +36,7 @@ const ProductStatusMapper = {
36
36
  globalProductID: productStatusV2.globalProductID,
37
37
  backordered: productStatusV2.backordered,
38
38
  backorderedAvailableDate: productStatusV2.backorderedAvailableDate,
39
+ locallyProduced: productStatusV2.locallyProduced,
39
40
  availableQuantity: productStatusV2.availableQuantity,
40
41
  webEnabled: productStatusV2.webEnabled,
41
42
  status: getStatusPartFromV2(productStatusV2),
@@ -44,8 +44,8 @@ const ProductUtils = {
44
44
  },
45
45
 
46
46
  mergeOrderTypes: function(previousOrderTypes, newOrderTypes) {
47
- // untrust previous order types
48
- const previousOrderTypesMapping = this.getOrderTypesMapping(previousOrderTypes, false);
47
+ // untrust previous order types, override them to false
48
+ const previousOrderTypesMapping = this.getOrderTypesMapping(previousOrderTypes, true);
49
49
 
50
50
  // trust new order types
51
51
  const newOrderTypesMapping = this.getOrderTypesMapping(newOrderTypes);
@@ -56,18 +56,24 @@ const ProductUtils = {
56
56
  };
57
57
  },
58
58
 
59
- getOrderTypesMapping: function(orderTypes, active = true) {
59
+ /**
60
+ * Gets the order types as a dictionary/mapping of order type to value
61
+ * @param {string[] | object[]} orderTypes - ex. ["adr", "order"] or { adr: false, order: true }
62
+ * @param {boolean} override - used to force the value of each orderType to false
63
+ * @returns {object} order types dictionary/mapping
64
+ */
65
+ getOrderTypesMapping: function(orderTypes, override = false) {
60
66
  if (isNullOrEmpty(orderTypes)) {
61
67
  return {};
62
68
  }
63
69
  const orderTypesMapping = {};
64
70
  if (Array.isArray(orderTypes)) {
65
71
  for (const orderType of orderTypes) {
66
- orderTypesMapping[orderType.toLowerCase()] = active;
72
+ orderTypesMapping[orderType.toLowerCase()] = !override;
67
73
  }
68
74
  } else {
69
75
  for (const orderType in orderTypes) {
70
- orderTypesMapping[orderType.toLowerCase()] = active;
76
+ orderTypesMapping[orderType.toLowerCase()] = !override && !!orderTypes[orderType];
71
77
  }
72
78
  }
73
79
  return orderTypesMapping;