@nuskin/ns-product-lib 2.5.0-cx24-2179.2.18 → 2.5.0-cx24-3282.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # [2.5.0-cx24-3282.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.19...v2.5.0-cx24-3282.1) (2023-02-02)
2
+
3
+
4
+ ### Fix
5
+
6
+ * Get test environment if not PROD ([b572755](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b5727553edfcec2d983e90560cf2ed5bad8792f1))
7
+
8
+ # [2.5.0-cx24-2179.2.19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.18...v2.5.0-cx24-2179.2.19) (2023-01-27)
9
+
10
+
11
+ ### Fix
12
+
13
+ * parent product customer types (#CX24-3175) ([411b2cc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/411b2cc5a7cf687152dc346579766c8f923b795a)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
14
+
15
+ ### Update
16
+
17
+ * clean ups - expose customerTypes (#CX24-3175) ([3b7d9b1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3b7d9b12a9cf815b11a8af61621ab9ebc76c37b5)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
18
+
1
19
  # [2.5.0-cx24-2179.2.18](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.17...v2.5.0-cx24-2179.2.18) (2023-01-26)
2
20
 
3
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.5.0-cx24-2179.2.18",
3
+ "version": "2.5.0-cx24-3282.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/index.js CHANGED
@@ -14,6 +14,7 @@ const ProductStatus = require("./models/productStatus.js");
14
14
  const ProductStatusMapper = require("./productStatusMapper.js");
15
15
  const ProductUtils = require("./productUtils.js");
16
16
  const ProductData = require("./productData.js");
17
+ const CustomerTypes = require('./models/customerTypes');
17
18
 
18
19
  module.exports = {
19
20
  Agelocme,
@@ -24,5 +25,6 @@ module.exports = {
24
25
  ProductStatus,
25
26
  ProductStatusMapper,
26
27
  ProductUtils,
27
- ProductData
28
+ ProductData,
29
+ CustomerTypes
28
30
  };
@@ -8,7 +8,7 @@ const CustomerTypes = require('./models/customerTypes');
8
8
  const ProductStatus = require("./models/productStatus");
9
9
  /** @type {*} */
10
10
  const ProductData = {
11
- /**
11
+ /**
12
12
  * @param {string[]} skus
13
13
  * @param {string} locale
14
14
  * @param {string} market
@@ -88,7 +88,7 @@ const ProductData = {
88
88
  /**
89
89
  * @param {contentstack.MarketConfig} marketConfig
90
90
  */
91
- getLegacyRequestHeaders: function(marketConfig) {
91
+ getLegacyRequestHeaders: function (marketConfig) {
92
92
  return {
93
93
  'Content-Type': 'application/json',
94
94
  client_id: marketConfig.checkout_client_id,
@@ -102,7 +102,7 @@ const ProductData = {
102
102
  * @param {*} eqVariant
103
103
  * @returns Array<Product>
104
104
  */
105
- eqProductVariantMapper : function (eqVariant) {
105
+ eqProductVariantMapper: function (eqVariant) {
106
106
 
107
107
  let imageURL = eqVariant.properties.imageURL;
108
108
  const regex = /\d+.\d+/
@@ -111,10 +111,10 @@ const ProductData = {
111
111
  if (imageURL.includes('contentstack')) {
112
112
  thumbnailImage = imageURL + '?width=40'
113
113
  } else {
114
- thumbnailImage = imageURL.replace(regex,'40.40')
114
+ thumbnailImage = imageURL.replace(regex, '40.40')
115
115
  }
116
116
 
117
- const { eventName, eventLabels, computedPrice, defaultProductPrice} = this.getEqProductPromotions(eqVariant);
117
+ const { eventName, eventLabels, computedPrice, defaultProductPrice } = this.getEqProductPromotions(eqVariant);
118
118
  const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
119
119
  const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
120
120
 
@@ -153,18 +153,18 @@ const ProductData = {
153
153
  <div class="sectionContent parsys">
154
154
  <div class="text parbase section">\n
155
155
  <p>
156
- Green tea has been used in China for thousands of years for its health-preserving and
157
- revitalizing power. Modern science has identified powerful antioxidants in green tea
158
- called polyphenols. One group of polyphenols called catechins is particularly potent
159
- and is highly effective at neutralizing free radicals at the cellular level. Catechins
160
- support healthy cell function while providing antioxidant protection to critical cell
161
- structures such as DNA. Clinical studies show catechins interfere with the production
162
- of certain enzymes involved in cell damage. Additionally, catechins have been demonstrated
163
- to cause a thermogenic effect that enhances the body s metabolic rate. Tegreen 97<sup>®</sup>
164
- from Pharmanex is a proprietary, highly concentrated extract of the catechins found
165
- in green tea. Tegreen 97<sup>®</sup> is one of the most potent antioxidant supplements
166
- on the market with a 97 percent polyphenol content, 65% catechins. Each Tegreen 97<sup>®</sup>
167
- capsule contains the catechin equivalent of approximately seven cups of green tea and is
156
+ Green tea has been used in China for thousands of years for its health-preserving and
157
+ revitalizing power. Modern science has identified powerful antioxidants in green tea
158
+ called polyphenols. One group of polyphenols called catechins is particularly potent
159
+ and is highly effective at neutralizing free radicals at the cellular level. Catechins
160
+ support healthy cell function while providing antioxidant protection to critical cell
161
+ structures such as DNA. Clinical studies show catechins interfere with the production
162
+ of certain enzymes involved in cell damage. Additionally, catechins have been demonstrated
163
+ to cause a thermogenic effect that enhances the body s metabolic rate. Tegreen 97<sup>®</sup>
164
+ from Pharmanex is a proprietary, highly concentrated extract of the catechins found
165
+ in green tea. Tegreen 97<sup>®</sup> is one of the most potent antioxidant supplements
166
+ on the market with a 97 percent polyphenol content, 65% catechins. Each Tegreen 97<sup>®</sup>
167
+ capsule contains the catechin equivalent of approximately seven cups of green tea and is
168
168
  99.5 percent caffeine free.
169
169
  </p>\r\n\n
170
170
  </div>\n\n
@@ -177,7 +177,7 @@ const ProductData = {
177
177
  <div>\n
178
178
  <div class="sectionContent parsys">
179
179
  <div class="text parbase section">\n
180
- <p>As a dietary supplement, take one (1) to four (4) capsules daily; preferably one (1)
180
+ <p>As a dietary supplement, take one (1) to four (4) capsules daily; preferably one (1)
181
181
  to two (2) each morning and evening with food. Store in a cool, dry place.</p>\r\n\n
182
182
  </div>\n\n
183
183
  </div>\n\n
@@ -205,7 +205,7 @@ const ProductData = {
205
205
  <tr>\r\n<td width="55%" colspan="3">* Daily Value not established</td>\r\n</tr>\r\n
206
206
  <tr>\r\n
207
207
  <td width="55%" colspan="3">
208
- <b>Other Ingredients: Gelatin, Silicon Dioxide,
208
+ <b>Other Ingredients: Gelatin, Silicon Dioxide,
209
209
  Microcrystalline Cellulose, Magnesium Stearate.</b>
210
210
  </td>\r\n</tr>\r\n
211
211
  </tbody>\r\n
@@ -223,8 +223,8 @@ const ProductData = {
223
223
  "availableQuantity": eqVariant.inventoryProperties.atpQty,
224
224
  "maxQuantity": 999,
225
225
  "points": "",
226
- "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
227
- "pv":eqVariant.priceFacets.PV,
226
+ "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
227
+ "pv": eqVariant.priceFacets.PV,
228
228
  "priceType": "WRTL",
229
229
  "price": discountedPrice,
230
230
  "priceMap": {
@@ -258,9 +258,9 @@ const ProductData = {
258
258
  "shade": "",
259
259
  "status": this.switchStatusFromEquinox(eqVariant.properties.status),
260
260
  "variantType": "Other",
261
- "variantDropdownLabel": eqVariant.properties.variantSelectLabel || "",
261
+ "variantDropdownLabel": eqVariant.properties.variantSelectLabel || "",
262
262
  "variantDropdownPlaceholder": "Select Type",
263
- "variantsLabel": eqVariant.properties.variantSelectLabel || "",
263
+ "variantsLabel": eqVariant.properties.variantSelectLabel || "",
264
264
  "groupOffer": false,
265
265
  "personalOffer": false,
266
266
  "savedEventName": eventName,
@@ -291,14 +291,14 @@ const ProductData = {
291
291
  if (!Array.isArray(product.promotion)) {
292
292
  return {
293
293
  eventLabels: "",
294
- computedPrice : 0,
294
+ computedPrice: 0,
295
295
  defaultProductPrice: product.priceFacets ? product.priceFacets["Regular Price"] : 0,
296
296
  eventName: null
297
297
  }
298
298
  }
299
299
 
300
- const defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
301
- const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
300
+ const defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
301
+ const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
302
302
  ? product.totalValue.priceAfterDiscount
303
303
  : 0;
304
304
  let eventName = "";
@@ -331,7 +331,7 @@ const ProductData = {
331
331
  if (imageURL.includes('contentstack')) {
332
332
  thumbnailImage = imageURL + '?width=40'
333
333
  } else {
334
- thumbnailImage = imageURL.replace(regex,'40.40')
334
+ thumbnailImage = imageURL.replace(regex, '40.40')
335
335
  }
336
336
 
337
337
  if (data.sku && data.sku.length > 1) {
@@ -386,7 +386,7 @@ const ProductData = {
386
386
  "availableQuantity": data.sku[count].inventoryProperties.atpQty,
387
387
  "maxQuantity": 999,
388
388
  "points": "",
389
- "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
389
+ "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
390
390
  "pv": data.sku[count].priceFacets.PV,
391
391
  "priceType": "WRTL",
392
392
  "price": discountedPrice,
@@ -411,7 +411,7 @@ const ProductData = {
411
411
  },
412
412
  "orderTypes": this._setOrderType(data.sku[count].properties),
413
413
  "childSkus": [],
414
- "custTypes": this.switchCustType(data.properties.customerTypes),
414
+ "custTypes": this.switchCustType(data.sku[count].properties.customerTypes),
415
415
  "division": data.properties.division,
416
416
  "backOrderDate": null,
417
417
  "locallyProduced": false,
@@ -422,9 +422,9 @@ const ProductData = {
422
422
  "shade": "",
423
423
  "status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
424
424
  "variantType": "Other",
425
- "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
425
+ "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
426
426
  "variantDropdownPlaceholder": "Select Type",
427
- "variantsLabel": data.sku[count].properties.variantLabel || "",
427
+ "variantsLabel": data.sku[count].properties.variantLabel || "",
428
428
  "groupOffer": false,
429
429
  "personalOffer": false,
430
430
  "savedEventName": eventName,
@@ -462,6 +462,13 @@ const ProductData = {
462
462
  };
463
463
  },
464
464
 
465
+ /**
466
+ *
467
+ * Map status from equinox to legacy
468
+ *
469
+ * @param {*} status
470
+ * @returns {string} productStatus
471
+ */
465
472
  switchStatusFromEquinox: function (status) {
466
473
  const { equinoxStatus } = ProductStatus;
467
474
  let newStatus = '';
@@ -476,7 +483,7 @@ const ProductData = {
476
483
  newStatus = ProductStatus.Discontinued;
477
484
  break;
478
485
  case equinoxStatus.STOPPED:
479
- newStatus = ProductStatus.Discontinued;
486
+ newStatus = ProductStatus.Discontinued;
480
487
  break;
481
488
  case equinoxStatus.REPLACEMENT:
482
489
  newStatus = ProductStatus.NotReleasedForSale;
@@ -490,13 +497,7 @@ const ProductData = {
490
497
  },
491
498
 
492
499
  /**
493
- *
494
- * @param {*} custType
495
- *
496
- */
497
-
498
- /**
499
- * map customer types from string to code
500
+ * map customer types from string to code<number>
500
501
  * @param {*} eqCustomerTypes
501
502
  * @returns
502
503
  */
@@ -531,7 +532,7 @@ const ProductData = {
531
532
 
532
533
  _sortProductsBySku: function (skus, products) {
533
534
 
534
- if(!skus || !products || products.length === 1) {
535
+ if (!skus || !products || products.length === 1) {
535
536
  return products
536
537
  }
537
538
 
@@ -606,7 +607,7 @@ function contentstackEnv() {
606
607
  return 'test';
607
608
  }
608
609
 
609
- return getEnvironmentFromUrl(window.location.host);
610
+ return (getEnvironmentFromUrl(window.location.host) != 'prod') ? 'test' : 'prod';
610
611
  }
611
612
 
612
613
  module.exports = ProductData;