@nuskin/ns-product-lib 2.5.0-cx24-2862.2 → 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 -12
- package/package.json +3 -3
- package/src/productData.js +120 -86
package/CHANGELOG.md
CHANGED
@@ -1,24 +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
|
-
*
|
6
|
+
* map equinox properties (CX24-2462) ([fdb813d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fdb813d6b2f5d9f877ffa870e4102e7d5e0dff07))
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
### Update
|
12
|
-
|
13
|
-
* set ADR pricing from equinox (CX24-2862) ([9f6dfb7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f6dfb726f40b1335411318629a2ebdf1b4dac96))
|
14
|
-
* set ADR pricing from equinox (CX24-2862) ([61f550a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/61f550a21c5cc9d062549ec2aaf2758aebccf2be))
|
15
|
-
|
16
|
-
## [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)
|
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)
|
17
9
|
|
18
10
|
|
19
11
|
### Fix
|
20
12
|
|
21
|
-
* [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))
|
22
14
|
|
23
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)
|
24
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": {
|
@@ -165,7 +165,19 @@ const ProductData = {
|
|
165
165
|
"WADW": eqVariant.priceFacets.PV,
|
166
166
|
"WHL": eqVariant.priceFacets.PV
|
167
167
|
},
|
168
|
-
"orderTypes":
|
168
|
+
"orderTypes": {
|
169
|
+
"adr": true,
|
170
|
+
"order": true,
|
171
|
+
"zpfc": false,
|
172
|
+
"zadp": true,
|
173
|
+
"ars": true,
|
174
|
+
"kiosk": true,
|
175
|
+
"mobile": true,
|
176
|
+
"preferred customer": true,
|
177
|
+
"retail": true,
|
178
|
+
"web": true,
|
179
|
+
"web display": true
|
180
|
+
},
|
169
181
|
"division": eqVariant.properties.division,
|
170
182
|
"backOrderDate": null,
|
171
183
|
"locallyProduced": false,
|
@@ -176,9 +188,9 @@ const ProductData = {
|
|
176
188
|
"shade": "",
|
177
189
|
"status": this.switchStatusFromEquinox(eqVariant.properties.status),
|
178
190
|
"variantType": "Other",
|
179
|
-
"variantDropdownLabel": eqVariant.properties.variantLabel
|
191
|
+
"variantDropdownLabel": eqVariant.properties.variantLabel || "",
|
180
192
|
"variantDropdownPlaceholder": "Select Type",
|
181
|
-
"variantsLabel": eqVariant.properties.variantLabel
|
193
|
+
"variantsLabel": eqVariant.properties.variantLabel || "",
|
182
194
|
"groupOffer": false,
|
183
195
|
"personalOffer": false,
|
184
196
|
"savedEventName": null,
|
@@ -211,7 +223,7 @@ const ProductData = {
|
|
211
223
|
if (imageURL.includes('contentstack')) {
|
212
224
|
thumbnailImage = imageURL + '?width=40'
|
213
225
|
} else {
|
214
|
-
thumbnailImage = imageURL.replace(regex,'40.40')
|
226
|
+
thumbnailImage = imageURL.replace(regex, '40.40')
|
215
227
|
}
|
216
228
|
|
217
229
|
if (data.sku && data.sku.length > 1) {
|
@@ -231,18 +243,19 @@ const ProductData = {
|
|
231
243
|
"longDescr": data.properties.productDetailsDescription,
|
232
244
|
"fullImage": imageURL,
|
233
245
|
"imageAltText": data.properties.name,
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
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
|
+
)) : [],
|
241
254
|
"thumbnail": thumbnailImage,
|
242
255
|
"ingredients": data.properties.ingredients,
|
243
|
-
|
244
|
-
|
245
|
-
|
256
|
+
benefits: mapBenefits(data.properties.benefits),
|
257
|
+
usage: mapUsage(data.properties.usage),
|
258
|
+
resources: mapResources(data.properties.resources),
|
246
259
|
"videos": "",
|
247
260
|
"movie": "",
|
248
261
|
"youtube": "",
|
@@ -256,16 +269,16 @@ const ProductData = {
|
|
256
269
|
"availableQuantity": data.sku[count].inventoryProperties.atpQty,
|
257
270
|
"maxQuantity": 999,
|
258
271
|
"points": "",
|
259
|
-
"cv": (data.sku[count].priceFacets.CV) ?
|
272
|
+
"cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
|
260
273
|
"pv": data.sku[count].priceFacets.PV,
|
261
274
|
"priceType": "WRTL",
|
262
275
|
"price": data.sku[count].priceFacets["Regular Price"],
|
263
276
|
"priceMap": {
|
264
277
|
"WRTL": data.sku[count].priceFacets["Regular Price"],
|
265
278
|
"WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
|
266
|
-
"WADR":
|
279
|
+
"WADR": 9999.01,
|
267
280
|
"RTL": data.sku[count].priceFacets["Regular Price"],
|
268
|
-
"WADW":
|
281
|
+
"WADW": 9998.01,
|
269
282
|
"WHL": data.sku[count].priceFacets["Wholesale Price"],
|
270
283
|
"WWHL": data.sku[count].priceFacets["Wholesale Price"]
|
271
284
|
},
|
@@ -279,7 +292,19 @@ const ProductData = {
|
|
279
292
|
"WADW": data.sku[count].priceFacets.PV,
|
280
293
|
"WHL": data.sku[count].priceFacets.PV
|
281
294
|
},
|
282
|
-
"orderTypes":
|
295
|
+
"orderTypes": {
|
296
|
+
"adr": true,
|
297
|
+
"order": true,
|
298
|
+
"zpfc": false,
|
299
|
+
"zadp": true,
|
300
|
+
"ars": true,
|
301
|
+
"kiosk": true,
|
302
|
+
"mobile": true,
|
303
|
+
"preferred customer": true,
|
304
|
+
"retail": true,
|
305
|
+
"web": true,
|
306
|
+
"web display": true
|
307
|
+
},
|
283
308
|
"childSkus": [],
|
284
309
|
"custTypes": this.switchCustType(data.properties.customerTypes),
|
285
310
|
"division": data.properties.division,
|
@@ -292,9 +317,9 @@ const ProductData = {
|
|
292
317
|
"shade": "",
|
293
318
|
"status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
|
294
319
|
"variantType": "Other",
|
295
|
-
"variantDropdownLabel": data.sku[count].properties.variantLabel
|
320
|
+
"variantDropdownLabel": data.sku[count].properties.variantLabel || "",
|
296
321
|
"variantDropdownPlaceholder": "Select Type",
|
297
|
-
"variantsLabel": data.sku[count].properties.variantLabel
|
322
|
+
"variantsLabel": data.sku[count].properties.variantLabel || "",
|
298
323
|
"groupOffer": false,
|
299
324
|
"personalOffer": false,
|
300
325
|
"savedEventName": null,
|
@@ -381,73 +406,82 @@ const ProductData = {
|
|
381
406
|
|
382
407
|
_sortProductsBySku: function (skus, products) {
|
383
408
|
|
384
|
-
if(!skus || !products || products.length === 1) {
|
409
|
+
if (!skus || !products || products.length === 1) {
|
385
410
|
return products
|
386
411
|
}
|
387
412
|
|
388
|
-
|
413
|
+
return products.sort(function (a, b) {
|
389
414
|
return skus.indexOf(a.sku) - skus.indexOf(b.sku);
|
390
415
|
});
|
391
416
|
|
392
|
-
|
417
|
+
}
|
418
|
+
}
|
393
419
|
|
394
|
-
|
420
|
+
function mapBenefits(benefits) {
|
421
|
+
if (!benefits) {
|
422
|
+
return {};
|
423
|
+
}
|
395
424
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
*
|
400
|
-
* This function is use to convert arsPhone,web,kiosk,mobile,subscription
|
401
|
-
* to orderType object
|
402
|
-
* "adr”
|
403
|
-
"order"
|
404
|
-
"zpfc"
|
405
|
-
"zadp"
|
406
|
-
"ars"
|
407
|
-
"kiosk"
|
408
|
-
"mobile"
|
409
|
-
"preferred customer"
|
410
|
-
"retail"
|
411
|
-
"web"
|
412
|
-
"web display"
|
413
|
-
*/
|
414
|
-
_setOrderType: function (properties) {
|
415
|
-
let orderTypeArr = {
|
416
|
-
"adr": false,
|
417
|
-
"order": false,
|
418
|
-
"zpfc": false,
|
419
|
-
"zadp": false,
|
420
|
-
"ars": false,
|
421
|
-
"kiosk": false,
|
422
|
-
"mobile": false,
|
423
|
-
"preferred customer": false,
|
424
|
-
"retail": false,
|
425
|
-
"web": false,
|
426
|
-
"web display": false
|
427
|
-
};
|
428
|
-
let availableChannelsArr = properties.availableChannels.split(',')
|
429
|
-
|
430
|
-
availableChannelsArr.forEach(channel => {
|
431
|
-
if (channel == 'arsPhone')
|
432
|
-
orderTypeArr.ars = true
|
433
|
-
if (channel == 'web') {
|
434
|
-
orderTypeArr.order = true
|
435
|
-
orderTypeArr.web = true
|
436
|
-
}
|
437
|
-
if (channel == 'kiosk')
|
438
|
-
orderTypeArr.kiosk = true
|
439
|
-
if (channel == 'mobile')
|
440
|
-
orderTypeArr.mobile = true
|
441
|
-
if (channel == 'subscription')
|
442
|
-
orderTypeArr.adr = true
|
425
|
+
const list = JSON.parse(benefits)
|
426
|
+
.map(item => item.benefits.map(benefit => benefit).join(''))
|
427
|
+
.join('');
|
443
428
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
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('');
|
481
|
+
|
482
|
+
return {
|
483
|
+
usageHTML: text,
|
484
|
+
usageText: 'Usage'
|
451
485
|
}
|
452
486
|
}
|
453
487
|
|