@nuskin/ns-product-lib 2.4.2-cx24-2612.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,9 +1,28 @@
1
- ## [2.4.2-cx24-2612.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.4.2-cx24-2612.1.1) (2022-11-07)
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
+
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)
9
+
10
+
11
+ ### Release
12
+
13
+ * Automated changes by GitLab pipeline [skip ci] ([62c7b7d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/62c7b7d38d24f3f267c859ae7f16af55f8d950f1))
14
+
15
+ ### Update
16
+
17
+ * map product images to carousel images (CX24-2462) ([1e17c6e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1e17c6ec39e54b4bdb2bb804c997eb14c9e501d5))
18
+ * map remaining equinox properties (CX24-2462) ([dafe0c0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/dafe0c0349207439d05ba0e45a71c8868a1d65bc))
19
+
20
+ ## [2.4.2-CX24.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.4.2-CX24.2.1) (2022-11-07)
2
21
 
3
22
 
4
23
  ### Fix
5
24
 
6
- * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([9d9d106](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9d9d10667477b4c7ef7bf8ec013aab322d3cdbcc))
25
+ * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([82611ca](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/82611cab93c990ed1ce05690feb9d00967090dea))
7
26
 
8
27
  ## [2.4.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.0...v2.4.1) (2022-11-06)
9
28
 
@@ -43,10 +62,13 @@
43
62
 
44
63
  * To make multiple products work (#CX24-2444) ([ce4c483](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ce4c483b7fbb0527e60045d8174fd503a67e63fa)), closes [#CX24-2444](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2444)
45
64
 
65
+ <<<<<<< HEAD
66
+ =======
46
67
  ### New
47
68
 
48
69
  * added support for inventory label (#CX24-2186) ([3e27481](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3e2748106cd6098086dbd6b738964deabacc875d)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
49
70
 
71
+ >>>>>>> CX24.2
50
72
  ### Release
51
73
 
52
74
  * Automated changes by GitLab pipeline [skip ci] ([8f75316](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8f75316b692ddccda5b7bea830ee6dc625b942c7))
@@ -54,6 +76,9 @@
54
76
 
55
77
  ### Update
56
78
 
79
+ <<<<<<< HEAD
80
+ * map product images to carousel images (CX24-2462) ([1e17c6e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1e17c6ec39e54b4bdb2bb804c997eb14c9e501d5))
81
+ =======
57
82
  * added support for variant and price (#CX24-2186) ([e0bf8f2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e0bf8f280a838dfa4cc613e5bc34d254dbdc8e1a)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
58
83
  * added variant label (#CX24-2186) ([4c223b3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4c223b34438ed73cb824716cacb93482486f8195)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
59
84
  * use platform-specific values when initialized ([18de006](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/18de006211ab396f4d7fa40d0089c8e185d9cee9))
@@ -72,6 +97,7 @@
72
97
 
73
98
  * added support for variant and price (#CX24-2186) ([e0bf8f2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e0bf8f280a838dfa4cc613e5bc34d254dbdc8e1a)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
74
99
  * added variant label (#CX24-2186) ([4c223b3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4c223b34438ed73cb824716cacb93482486f8195)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
100
+ >>>>>>> CX24.2
75
101
 
76
102
  # [2.3.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.2.0...v2.3.0) (2022-10-14)
77
103
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.4.2-cx24-2612.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": {
@@ -81,7 +81,7 @@ const ProductData = {
81
81
  /**
82
82
  * @param {contentstack.MarketConfig} marketConfig
83
83
  */
84
- getLegacyRequestHeaders: function(marketConfig) {
84
+ getLegacyRequestHeaders: function (marketConfig) {
85
85
  return {
86
86
  'Content-Type': 'application/json',
87
87
  client_id: marketConfig.checkout_client_id,
@@ -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,
@@ -223,7 +223,7 @@ const ProductData = {
223
223
  if (imageURL.includes('contentstack')) {
224
224
  thumbnailImage = imageURL + '?width=40'
225
225
  } else {
226
- thumbnailImage = imageURL.replace(regex,'40.40')
226
+ thumbnailImage = imageURL.replace(regex, '40.40')
227
227
  }
228
228
 
229
229
  if (data.sku && data.sku.length > 1) {
@@ -243,18 +243,19 @@ const ProductData = {
243
243
  "longDescr": data.properties.productDetailsDescription,
244
244
  "fullImage": imageURL,
245
245
  "imageAltText": data.properties.name,
246
- "productCarouselImages": [
247
- {
248
- "contentType": "img",
249
- "src": "/content/products/24/00/35/24003529/jcr:content/fullImage.imgw.1280.1280.png",
250
- "alt": ""
251
- }
252
- ],
246
+ productCarouselImages: data.sku[count].properties.productImages
247
+ ? JSON.parse(data.sku[count].properties.productImages).map(img => (
248
+ {
249
+ contentType: /\.jpg/i.test(img.url) ? 'img' : 'video',
250
+ src: img.url,
251
+ alt: img.alt
252
+ }
253
+ )) : [],
253
254
  "thumbnail": thumbnailImage,
254
- "ingredients": data.properties.ingredients,
255
- "benefits": data.properties.benefits,
256
- "usage": data.properties.usage,
257
- "resources": data.sku[count].properties.resources,
255
+ ingredients: mapIngredients(data.properties.ingredients),
256
+ benefits: mapBenefits(data.properties.benefits),
257
+ usage: mapUsage(data.properties.usage),
258
+ resources: mapResources(data.properties.resources),
258
259
  "videos": "",
259
260
  "movie": "",
260
261
  "youtube": "",
@@ -268,7 +269,7 @@ const ProductData = {
268
269
  "availableQuantity": data.sku[count].inventoryProperties.atpQty,
269
270
  "maxQuantity": 999,
270
271
  "points": "",
271
- "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
272
+ "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
272
273
  "pv": data.sku[count].priceFacets.PV,
273
274
  "priceType": "WRTL",
274
275
  "price": data.sku[count].priceFacets["Regular Price"],
@@ -316,9 +317,9 @@ const ProductData = {
316
317
  "shade": "",
317
318
  "status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
318
319
  "variantType": "Other",
319
- "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
320
+ "variantDropdownLabel": data.sku[count].properties.variantLabel || "",
320
321
  "variantDropdownPlaceholder": "Select Type",
321
- "variantsLabel": data.sku[count].properties.variantLabel || "",
322
+ "variantsLabel": data.sku[count].properties.variantLabel || "",
322
323
  "groupOffer": false,
323
324
  "personalOffer": false,
324
325
  "savedEventName": null,
@@ -405,16 +406,82 @@ const ProductData = {
405
406
 
406
407
  _sortProductsBySku: function (skus, products) {
407
408
 
408
- if(!skus || !products || products.length === 1) {
409
+ if (!skus || !products || products.length === 1) {
409
410
  return products
410
411
  }
411
412
 
412
- const sortedProducts = products.sort(function (a, b) {
413
+ return products.sort(function (a, b) {
413
414
  return skus.indexOf(a.sku) - skus.indexOf(b.sku);
414
415
  });
415
416
 
416
- return sortedProducts
417
+ }
418
+ }
419
+
420
+ function mapBenefits(benefits) {
421
+ if (!benefits) {
422
+ return {};
423
+ }
424
+
425
+ const list = JSON.parse(benefits)
426
+ .map(item => item.benefits.map(benefit => benefit).join(''))
427
+ .join('');
428
+
429
+ return {
430
+ benefitsHTML: list,
431
+ benefitsText: 'Benefits',
432
+ benefitItems: []
433
+ };
434
+ }
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
+
458
+ function mapResources(resources) {
459
+ if (!resources) {
460
+ return {};
461
+ }
462
+
463
+ const text = JSON.parse(resources)
464
+ .map(res => `<p><a href="${res.url}" target="_blank">${res.title}</a></p>`)
465
+ .join('');
466
+
467
+ return {
468
+ resourcesHTML: text,
469
+ resourcesText: 'Resources',
470
+ resourceLinks: []
471
+ }
472
+ }
473
+
474
+ function mapUsage(usage) {
475
+ if (!usage) {
476
+ return {};
477
+ }
478
+
479
+ const text = JSON.parse(usage).additionalText
480
+ .map(t => t).join('');
417
481
 
482
+ return {
483
+ usageHTML: text,
484
+ usageText: 'Usage'
418
485
  }
419
486
  }
420
487