@nuskin/ns-product-lib 2.5.0-cx24-2462.1.1 → 2.5.0-cx24-2462.1.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [2.5.0-cx24-2462.1.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2462.1.1...v2.5.0-cx24-2462.1.2) (2022-11-08)
2
+
3
+
4
+ ### Update
5
+
6
+ * map remaining equinox properties (CX24-2462) ([66e320d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/66e320dfcf0b9e35f7fb2adeb1cdfe5308f51850))
7
+
1
8
  # [2.5.0-cx24-2462.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-CX24.2.1...v2.5.0-cx24-2462.1.1) (2022-11-07)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.5.0-cx24-2462.1.1",
3
+ "version": "2.5.0-cx24-2462.1.2",
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": {
@@ -95,7 +95,7 @@ const ProductData = {
95
95
  * @param {*} eqVariant
96
96
  * @returns Array<Product>
97
97
  */
98
- eqProductVariantMapper : function (eqVariant) {
98
+ eqProductVariantMapper: function (eqVariant) {
99
99
 
100
100
  let imageURL = eqVariant.properties.imageURL;
101
101
  const regex = /\d+.\d+/
@@ -104,7 +104,7 @@ const ProductData = {
104
104
  if (imageURL.includes('contentstack')) {
105
105
  thumbnailImage = imageURL + '?width=40'
106
106
  } else {
107
- thumbnailImage = imageURL.replace(regex,'40.40')
107
+ thumbnailImage = imageURL.replace(regex, '40.40')
108
108
  }
109
109
 
110
110
  return {
@@ -125,7 +125,7 @@ const ProductData = {
125
125
  }
126
126
  ],
127
127
  "thumbnail": thumbnailImage,
128
- "ingredients": eqVariant.properties.ingredients,
128
+ ingredients: mapIngredients(eqVariant.properties.ingredients),
129
129
  "benefits": eqVariant.properties.benefits,
130
130
  "usage": eqVariant.properties.usage,
131
131
  "resources": eqVariant.properties.resources,
@@ -142,8 +142,8 @@ const ProductData = {
142
142
  "availableQuantity": eqVariant.inventoryProperties.atpQty,
143
143
  "maxQuantity": 999,
144
144
  "points": "",
145
- "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
146
- "pv":eqVariant.priceFacets.PV,
145
+ "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
146
+ "pv": eqVariant.priceFacets.PV,
147
147
  "priceType": "WRTL",
148
148
  "price": eqVariant.priceFacets["Regular Price"],
149
149
  "priceMap": {
@@ -188,9 +188,9 @@ const ProductData = {
188
188
  "shade": "",
189
189
  "status": this.switchStatusFromEquinox(eqVariant.properties.status),
190
190
  "variantType": "Other",
191
- "variantDropdownLabel": eqVariant.properties.variantLabel || "",
191
+ "variantDropdownLabel": eqVariant.properties.variantLabel || "",
192
192
  "variantDropdownPlaceholder": "Select Type",
193
- "variantsLabel": eqVariant.properties.variantLabel || "",
193
+ "variantsLabel": eqVariant.properties.variantLabel || "",
194
194
  "groupOffer": false,
195
195
  "personalOffer": false,
196
196
  "savedEventName": null,
@@ -252,7 +252,7 @@ const ProductData = {
252
252
  }
253
253
  )) : [],
254
254
  "thumbnail": thumbnailImage,
255
- "ingredients": data.properties.ingredients,
255
+ ingredients: mapIngredients(data.properties.ingredients),
256
256
  benefits: mapBenefits(data.properties.benefits),
257
257
  usage: mapUsage(data.properties.usage),
258
258
  resources: mapResources(data.properties.resources),
@@ -317,9 +317,9 @@ const ProductData = {
317
317
  "shade": "",
318
318
  "status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
319
319
  "variantType": "Other",
320
- "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
320
+ "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
321
321
  "variantDropdownPlaceholder": "Select Type",
322
- "variantsLabel": data.sku[count].properties.variantLabel || "",
322
+ "variantsLabel": data.sku[count].properties.variantLabel || "",
323
323
  "groupOffer": false,
324
324
  "personalOffer": false,
325
325
  "savedEventName": null,
@@ -406,7 +406,7 @@ const ProductData = {
406
406
 
407
407
  _sortProductsBySku: function (skus, products) {
408
408
 
409
- if(!skus || !products || products.length === 1) {
409
+ if (!skus || !products || products.length === 1) {
410
410
  return products
411
411
  }
412
412
 
@@ -433,6 +433,28 @@ function mapBenefits(benefits) {
433
433
  };
434
434
  }
435
435
 
436
+ function mapIngredients(ingredients) {
437
+ if (!mapIngredients) {
438
+ return {};
439
+ }
440
+
441
+ // concatenating the name, description, keyIngredients, and otherIngredients
442
+ const list = JSON.parse(ingredients)
443
+ .map(i => [
444
+ i.keyIngredients
445
+ .map(k => `<img src="${k.image.url}" alt="${k.image.alt}" /> ${k.name} ${k.description}`)
446
+ .join(' '),
447
+ i.otherIngredients
448
+ ].join(' '))
449
+ .join(' ');
450
+
451
+ return {
452
+ ingredientsHTML: list,
453
+ ingredientsText: 'Ingredients',
454
+ ingredients: []
455
+ }
456
+ }
457
+
436
458
  function mapResources(resources) {
437
459
  if (!resources) {
438
460
  return {};