@nuskin/ns-product-lib 2.5.0-cx24-2862.1 → 2.5.0-cx24-2462.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -5
- package/package.json +3 -3
- package/src/productData.js +96 -29
package/CHANGELOG.md
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
# [2.5.0-cx24-
|
1
|
+
# [2.5.0-cx24-2462.3.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.3.1) (2022-11-15)
|
2
2
|
|
3
3
|
|
4
4
|
### Update
|
5
5
|
|
6
|
-
*
|
7
|
-
* set ADR pricing from equinox (CX24-2862) ([61f550a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/61f550a21c5cc9d062549ec2aaf2758aebccf2be))
|
6
|
+
* map equinox properties (CX24-2462) ([fdb813d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fdb813d6b2f5d9f877ffa870e4102e7d5e0dff07))
|
8
7
|
|
9
|
-
## [2.4.2-
|
8
|
+
## [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)
|
10
9
|
|
11
10
|
|
12
11
|
### Fix
|
13
12
|
|
14
|
-
* [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([
|
13
|
+
* [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))
|
15
14
|
|
16
15
|
## [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)
|
17
16
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.5.0-cx24-
|
3
|
+
"version": "2.5.0-cx24-2462.3.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": {
|
@@ -25,8 +25,8 @@
|
|
25
25
|
"eslint-config-prettier": "4.1.0",
|
26
26
|
"eslint-plugin-json": "2.1.1",
|
27
27
|
"eslint-plugin-prettier": "3.1.2",
|
28
|
-
"jest": "
|
29
|
-
"jest-environment-jsdom": "
|
28
|
+
"jest": "26.0.1",
|
29
|
+
"jest-environment-jsdom": "26.0.1",
|
30
30
|
"jest-sonar-reporter": "2.0.0",
|
31
31
|
"prettier": "1.19.1"
|
32
32
|
},
|
package/src/productData.js
CHANGED
@@ -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
|
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
|
-
|
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,17 +142,17 @@ const ProductData = {
|
|
142
142
|
"availableQuantity": eqVariant.inventoryProperties.atpQty,
|
143
143
|
"maxQuantity": 999,
|
144
144
|
"points": "",
|
145
|
-
"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": {
|
150
150
|
"WRTL": eqVariant.priceFacets["Regular Price"],
|
151
151
|
"WADW-WRTL": eqVariant.priceFacets["Regular Price"],
|
152
|
-
"WADR":
|
152
|
+
"WADR": 9999.01,
|
153
153
|
"RTL": eqVariant.priceFacets["Regular Price"],
|
154
154
|
"WWHL": eqVariant.priceFacets["Wholesale Price"],
|
155
|
-
"WADW":
|
155
|
+
"WADW": 9998.01,
|
156
156
|
"WHL": eqVariant.priceFacets["Wholesale Price"]
|
157
157
|
},
|
158
158
|
"cvMap": {
|
@@ -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
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
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
255
|
"ingredients": data.properties.ingredients,
|
255
|
-
|
256
|
-
|
257
|
-
|
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,16 +269,16 @@ const ProductData = {
|
|
268
269
|
"availableQuantity": data.sku[count].inventoryProperties.atpQty,
|
269
270
|
"maxQuantity": 999,
|
270
271
|
"points": "",
|
271
|
-
"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"],
|
275
276
|
"priceMap": {
|
276
277
|
"WRTL": data.sku[count].priceFacets["Regular Price"],
|
277
278
|
"WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
|
278
|
-
"WADR":
|
279
|
+
"WADR": 9999.01,
|
279
280
|
"RTL": data.sku[count].priceFacets["Regular Price"],
|
280
|
-
"WADW":
|
281
|
+
"WADW": 9998.01,
|
281
282
|
"WHL": data.sku[count].priceFacets["Wholesale Price"],
|
282
283
|
"WWHL": data.sku[count].priceFacets["Wholesale Price"]
|
283
284
|
},
|
@@ -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
|
-
|
413
|
+
return products.sort(function (a, b) {
|
413
414
|
return skus.indexOf(a.sku) - skus.indexOf(b.sku);
|
414
415
|
});
|
415
416
|
|
416
|
-
|
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
|
|