@nuskin/ns-product-lib 2.5.0-cx24-2462.3.3 → 2.5.0-cx24-2467.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +26 -8
- package/package.json +3 -3
- package/src/productData.js +91 -124
package/CHANGELOG.md
CHANGED
@@ -1,30 +1,48 @@
|
|
1
|
-
# [2.5.0-cx24-
|
1
|
+
# [2.5.0-cx24-2467.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-2467.3.1) (2022-11-22)
|
2
2
|
|
3
3
|
|
4
|
+
### Fix
|
5
|
+
|
6
|
+
* [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([a89af4a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a89af4a5d00c6a68fcaeff22f128554270add21e))
|
7
|
+
|
8
|
+
### New
|
9
|
+
|
10
|
+
* exclude base sku in variants (#CX24-2467) ([e20697b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e20697b815e9001ec3ae888eeb9e005f88798056)), closes [#CX24-2467](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2467)
|
11
|
+
|
12
|
+
### Release
|
13
|
+
|
14
|
+
* Automated changes by GitLab pipeline [skip ci] ([07bfa40](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/07bfa404c552c05637c2c8a537c4ff298536874e))
|
15
|
+
* Automated changes by GitLab pipeline [skip ci] ([fa1c0d9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fa1c0d9d5853482e3ac49cea4e99599e7192f85b))
|
16
|
+
* Automated changes by GitLab pipeline [skip ci] ([2d20787](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2d2078763b2d57edb8a24f438ac90dd37c3ff41b))
|
17
|
+
|
4
18
|
### Update
|
5
19
|
|
6
|
-
*
|
20
|
+
* set ADR pricing from equinox (CX24-2862) ([65d04d2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/65d04d2e9ff4018edfe99e5a7412bee985d3def2))
|
21
|
+
* set ADR pricing from equinox (CX24-2862) ([54a5693](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/54a56932e5df36c9c30ce6358d8597c98be3d20d))
|
22
|
+
* set ADR pricing from equinox (CX24-2862) ([bbd135f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bbd135f1ed0395c578be2274c84ba136ceed9376))
|
23
|
+
* set ADR pricing from equinox (CX24-2862) ([197003e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/197003e1629bd394c547a118d332b5e8574dfc7d))
|
7
24
|
|
8
|
-
# [2.5.0-cx24-
|
25
|
+
# [2.5.0-cx24-2862.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2862.1...v2.5.0-cx24-2862.2) (2022-11-11)
|
9
26
|
|
10
27
|
|
11
28
|
### Update
|
12
29
|
|
13
|
-
*
|
30
|
+
* set ADR pricing from equinox (CX24-2862) ([b64dcea](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b64dcea4dd3374be992c667db5c0b2604aacc029))
|
14
31
|
|
15
|
-
# [2.5.0-cx24-
|
32
|
+
# [2.5.0-cx24-2862.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-cx24-2612.1.1...v2.5.0-cx24-2862.1) (2022-11-10)
|
16
33
|
|
17
34
|
|
18
35
|
### Update
|
19
36
|
|
20
|
-
*
|
37
|
+
* set ADR pricing from equinox (CX24-2862) ([9f6dfb7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f6dfb726f40b1335411318629a2ebdf1b4dac96))
|
38
|
+
* set ADR pricing from equinox (CX24-2862) ([61f550a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/61f550a21c5cc9d062549ec2aaf2758aebccf2be))
|
21
39
|
|
22
|
-
## [2.4.2-
|
40
|
+
## [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)
|
23
41
|
|
24
42
|
|
25
43
|
### Fix
|
26
44
|
|
27
|
-
* [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([
|
45
|
+
* [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))
|
28
46
|
|
29
47
|
## [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)
|
30
48
|
|
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-2467.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": "29.2.2",
|
29
|
+
"jest-environment-jsdom": "29.2.2",
|
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
|
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,
|
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:
|
128
|
+
"ingredients": 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":
|
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": eqVariant.priceFacets["Regular Price"],
|
153
153
|
"RTL": eqVariant.priceFacets["Regular Price"],
|
154
154
|
"WWHL": eqVariant.priceFacets["Wholesale Price"],
|
155
|
-
"WADW":
|
155
|
+
"WADW": eqVariant.priceFacets["Wholesale Price"],
|
156
156
|
"WHL": eqVariant.priceFacets["Wholesale Price"]
|
157
157
|
},
|
158
158
|
"cvMap": {
|
@@ -165,19 +165,7 @@ const ProductData = {
|
|
165
165
|
"WADW": eqVariant.priceFacets.PV,
|
166
166
|
"WHL": eqVariant.priceFacets.PV
|
167
167
|
},
|
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
|
-
},
|
168
|
+
"orderTypes": this._setOrderType(eqVariant.properties),
|
181
169
|
"division": eqVariant.properties.division,
|
182
170
|
"backOrderDate": null,
|
183
171
|
"locallyProduced": false,
|
@@ -188,9 +176,9 @@ const ProductData = {
|
|
188
176
|
"shade": "",
|
189
177
|
"status": this.switchStatusFromEquinox(eqVariant.properties.status),
|
190
178
|
"variantType": "Other",
|
191
|
-
"variantDropdownLabel": eqVariant.properties.variantLabel
|
179
|
+
"variantDropdownLabel": eqVariant.properties.variantLabel || "",
|
192
180
|
"variantDropdownPlaceholder": "Select Type",
|
193
|
-
"variantsLabel": eqVariant.properties.variantLabel
|
181
|
+
"variantsLabel": eqVariant.properties.variantLabel || "",
|
194
182
|
"groupOffer": false,
|
195
183
|
"personalOffer": false,
|
196
184
|
"savedEventName": null,
|
@@ -223,14 +211,15 @@ const ProductData = {
|
|
223
211
|
if (imageURL.includes('contentstack')) {
|
224
212
|
thumbnailImage = imageURL + '?width=40'
|
225
213
|
} else {
|
226
|
-
thumbnailImage = imageURL.replace(regex,
|
214
|
+
thumbnailImage = imageURL.replace(regex,'40.40')
|
227
215
|
}
|
228
216
|
|
229
217
|
if (data.sku && data.sku.length > 1) {
|
230
|
-
data.sku.
|
231
|
-
|
232
|
-
|
233
|
-
|
218
|
+
data.sku.filter(variant => variant.sku.substring(2, 4) !== "55")
|
219
|
+
.map(variant => {
|
220
|
+
variants[variant.identifier] = this.eqProductVariantMapper(variant);
|
221
|
+
return variant;
|
222
|
+
});
|
234
223
|
}
|
235
224
|
|
236
225
|
prod = {
|
@@ -243,19 +232,18 @@ const ProductData = {
|
|
243
232
|
"longDescr": data.properties.productDetailsDescription,
|
244
233
|
"fullImage": imageURL,
|
245
234
|
"imageAltText": data.properties.name,
|
246
|
-
productCarouselImages:
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
)) : [],
|
235
|
+
"productCarouselImages": [
|
236
|
+
{
|
237
|
+
"contentType": "img",
|
238
|
+
"src": "/content/products/24/00/35/24003529/jcr:content/fullImage.imgw.1280.1280.png",
|
239
|
+
"alt": ""
|
240
|
+
}
|
241
|
+
],
|
254
242
|
"thumbnail": thumbnailImage,
|
255
|
-
ingredients:
|
256
|
-
benefits:
|
257
|
-
usage:
|
258
|
-
resources:
|
243
|
+
"ingredients": data.properties.ingredients,
|
244
|
+
"benefits": data.properties.benefits,
|
245
|
+
"usage": data.properties.usage,
|
246
|
+
"resources": data.sku[count].properties.resources,
|
259
247
|
"videos": "",
|
260
248
|
"movie": "",
|
261
249
|
"youtube": "",
|
@@ -269,16 +257,16 @@ const ProductData = {
|
|
269
257
|
"availableQuantity": data.sku[count].inventoryProperties.atpQty,
|
270
258
|
"maxQuantity": 999,
|
271
259
|
"points": "",
|
272
|
-
"cv": (data.sku[count].priceFacets.CV) ?
|
260
|
+
"cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
|
273
261
|
"pv": data.sku[count].priceFacets.PV,
|
274
262
|
"priceType": "WRTL",
|
275
263
|
"price": data.sku[count].priceFacets["Regular Price"],
|
276
264
|
"priceMap": {
|
277
265
|
"WRTL": data.sku[count].priceFacets["Regular Price"],
|
278
266
|
"WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
|
279
|
-
"WADR":
|
267
|
+
"WADR": data.sku[count].priceFacets["Regular Price"],
|
280
268
|
"RTL": data.sku[count].priceFacets["Regular Price"],
|
281
|
-
"WADW":
|
269
|
+
"WADW": data.sku[count].priceFacets["Wholesale Price"],
|
282
270
|
"WHL": data.sku[count].priceFacets["Wholesale Price"],
|
283
271
|
"WWHL": data.sku[count].priceFacets["Wholesale Price"]
|
284
272
|
},
|
@@ -292,19 +280,7 @@ const ProductData = {
|
|
292
280
|
"WADW": data.sku[count].priceFacets.PV,
|
293
281
|
"WHL": data.sku[count].priceFacets.PV
|
294
282
|
},
|
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
|
+
"orderTypes": this._setOrderType(data.sku[count].properties),
|
308
284
|
"childSkus": [],
|
309
285
|
"custTypes": this.switchCustType(data.properties.customerTypes),
|
310
286
|
"division": data.properties.division,
|
@@ -317,9 +293,9 @@ const ProductData = {
|
|
317
293
|
"shade": "",
|
318
294
|
"status": this.switchStatusFromEquinox(data.sku[count].properties.productStatus),
|
319
295
|
"variantType": "Other",
|
320
|
-
"variantDropdownLabel": data.sku[count].properties.variantLabel
|
296
|
+
"variantDropdownLabel": data.sku[count].properties.variantLabel || "",
|
321
297
|
"variantDropdownPlaceholder": "Select Type",
|
322
|
-
"variantsLabel": data.sku[count].properties.variantLabel
|
298
|
+
"variantsLabel": data.sku[count].properties.variantLabel || "",
|
323
299
|
"groupOffer": false,
|
324
300
|
"personalOffer": false,
|
325
301
|
"savedEventName": null,
|
@@ -406,82 +382,73 @@ const ProductData = {
|
|
406
382
|
|
407
383
|
_sortProductsBySku: function (skus, products) {
|
408
384
|
|
409
|
-
if
|
385
|
+
if(!skus || !products || products.length === 1) {
|
410
386
|
return products
|
411
387
|
}
|
412
388
|
|
413
|
-
|
389
|
+
const sortedProducts = products.sort(function (a, b) {
|
414
390
|
return skus.indexOf(a.sku) - skus.indexOf(b.sku);
|
415
391
|
});
|
416
392
|
|
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
|
-
}
|
393
|
+
return sortedProducts
|
435
394
|
|
436
|
-
|
437
|
-
if (!ingredients) {
|
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
|
-
}
|
395
|
+
},
|
473
396
|
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
397
|
+
/**
|
398
|
+
*
|
399
|
+
* @param {*} availableChannels
|
400
|
+
*
|
401
|
+
* This function is use to convert arsPhone,web,kiosk,mobile,subscription
|
402
|
+
* to orderType object
|
403
|
+
* "adr”
|
404
|
+
"order"
|
405
|
+
"zpfc"
|
406
|
+
"zadp"
|
407
|
+
"ars"
|
408
|
+
"kiosk"
|
409
|
+
"mobile"
|
410
|
+
"preferred customer"
|
411
|
+
"retail"
|
412
|
+
"web"
|
413
|
+
"web display"
|
414
|
+
*/
|
415
|
+
_setOrderType: function (properties) {
|
416
|
+
let orderTypeArr = {
|
417
|
+
"adr": false,
|
418
|
+
"order": false,
|
419
|
+
"zpfc": false,
|
420
|
+
"zadp": false,
|
421
|
+
"ars": false,
|
422
|
+
"kiosk": false,
|
423
|
+
"mobile": false,
|
424
|
+
"preferred customer": false,
|
425
|
+
"retail": false,
|
426
|
+
"web": false,
|
427
|
+
"web display": false
|
428
|
+
};
|
429
|
+
let availableChannelsArr = properties.availableChannels.split(',')
|
430
|
+
|
431
|
+
availableChannelsArr.forEach(channel => {
|
432
|
+
if (channel == 'arsPhone')
|
433
|
+
orderTypeArr.ars = true
|
434
|
+
if (channel == 'web') {
|
435
|
+
orderTypeArr.order = true
|
436
|
+
orderTypeArr.web = true
|
437
|
+
}
|
438
|
+
if (channel == 'kiosk')
|
439
|
+
orderTypeArr.kiosk = true
|
440
|
+
if (channel == 'mobile')
|
441
|
+
orderTypeArr.mobile = true
|
442
|
+
if (channel == 'subscription')
|
443
|
+
orderTypeArr.adr = true
|
478
444
|
|
479
|
-
|
480
|
-
|
445
|
+
});
|
446
|
+
if (properties.retail)
|
447
|
+
orderTypeArr.retail = true
|
448
|
+
if (properties.prefferredCustomer)
|
449
|
+
orderTypeArr['preferred customer'] = true
|
481
450
|
|
482
|
-
|
483
|
-
usageHTML: text,
|
484
|
-
usageText: 'Usage'
|
451
|
+
return orderTypeArr;
|
485
452
|
}
|
486
453
|
}
|
487
454
|
|