@nuskin/ns-product-lib 2.7.0-cx24-3682.5 → 2.7.0-cx24-3702.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +11 -20
- package/package.json +2 -2
- package/src/equinox-helpers/index.js +0 -5
- package/src/productData.js +42 -26
- package/src/equinox-helpers/interceptors/index.js +0 -5
- package/src/equinox-helpers/interceptors/productNotFound.js +0 -49
- package/src/models/productNotFound.js +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,39 +1,30 @@
|
|
1
|
-
# [2.7.0-cx24-
|
1
|
+
# [2.7.0-cx24-3702.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.2...v2.7.0-cx24-3702.1) (2023-03-25)
|
2
2
|
|
3
3
|
|
4
4
|
### New
|
5
5
|
|
6
|
-
*
|
6
|
+
* adding properties variable to equinox product data ([3a4971b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3a4971bc3620ac848c0ba6c541bf6906b09169fd))
|
7
7
|
|
8
|
-
|
8
|
+
## [2.6.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1...v2.6.2) (2023-03-24)
|
9
9
|
|
10
10
|
|
11
|
-
###
|
12
|
-
|
13
|
-
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([f55854a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f55854ad4abb17dbd373fe5e36a38deb2bb8fc53)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
14
|
-
|
15
|
-
# [2.7.0-cx24-3682.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.2...v2.7.0-cx24-3682.3) (2023-03-24)
|
16
|
-
|
17
|
-
|
18
|
-
### New
|
11
|
+
### Fix
|
19
12
|
|
20
|
-
*
|
13
|
+
* Fix drop down variants Cx24 3377 ([262328e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/262328e617b87d6dbf44b1393fdffaa10d8de13d))
|
21
14
|
|
22
|
-
# [2.7.0-cx24-
|
15
|
+
# [2.7.0-cx24-337703.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.2-cx24-337703.1...v2.7.0-cx24-337703.1) (2023-03-22)
|
23
16
|
|
24
17
|
|
25
|
-
###
|
18
|
+
### Update
|
26
19
|
|
27
|
-
*
|
28
|
-
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([b86a1d2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b86a1d2610892564c643bd851d873e507efedd49)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
29
|
-
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([60d61cc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60d61ccd38e9b971b7ac53cf4224a9897a63fef4)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
20
|
+
* Merge CX24-3563 changes to CX24-337703 ([9e6ca40](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9e6ca40c35252c24394351275a234e9847f70bfc))
|
30
21
|
|
31
|
-
|
22
|
+
## [2.6.2-cx24-337703.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1...v2.6.2-cx24-337703.1) (2023-03-22)
|
32
23
|
|
33
24
|
|
34
|
-
###
|
25
|
+
### Fix
|
35
26
|
|
36
|
-
*
|
27
|
+
* Show dropdown for variants ([85cdf69](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/85cdf69cc2bbf6700ec5c9bcacc7222cf2ddf674))
|
37
28
|
|
38
29
|
## [2.6.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0...v2.6.1) (2023-03-16)
|
39
30
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.7.0-cx24-
|
3
|
+
"version": "2.7.0-cx24-3702.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": {
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"dependencies": {
|
34
34
|
"@nuskin/configuration-sdk": "2.2.3",
|
35
35
|
"@nuskin/ns-common-lib": "1.4.5",
|
36
|
-
"@nuskin/ns-util": "4.2.
|
36
|
+
"@nuskin/ns-util": "4.2.7",
|
37
37
|
"axios": "0.27.2",
|
38
38
|
"qs": "6.11.0"
|
39
39
|
},
|
@@ -15,11 +15,6 @@
|
|
15
15
|
* @property {Inventory} [inventory]
|
16
16
|
*
|
17
17
|
* ---
|
18
|
-
*
|
19
|
-
* @description This model represents the response.
|
20
|
-
* @typedef EquinoxResponse
|
21
|
-
* @type {object}
|
22
|
-
* @property {EquinoxProduct} product
|
23
18
|
*
|
24
19
|
* @description This model represents a product within an Equinox response.
|
25
20
|
* @typedef EquinoxProduct
|
package/src/productData.js
CHANGED
@@ -6,7 +6,6 @@ const Product = require("./product");
|
|
6
6
|
const CustomerTypes = require('./models/customerTypes');
|
7
7
|
const ProductStatus = require("./models/productStatus");
|
8
8
|
const { mapAvailableQuantity, mapChildSKU } = require('./equinox-helpers');
|
9
|
-
const { productNotFoundInterceptor } = require('./equinox-helpers/interceptors');
|
10
9
|
|
11
10
|
const productTypes = {
|
12
11
|
kit: 'kit'
|
@@ -67,11 +66,9 @@ const ProductData = {
|
|
67
66
|
}
|
68
67
|
|
69
68
|
const filter = skuFilter.join(" OR ")
|
70
|
-
//axios.defaults.withCredentials = true;
|
71
69
|
|
72
70
|
const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
|
73
71
|
const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
|
74
|
-
axios.interceptors.response.use((res) => res, productNotFoundInterceptor);
|
75
72
|
const response = await axios.request({
|
76
73
|
method: 'get',
|
77
74
|
url: href,
|
@@ -84,7 +81,6 @@ const ProductData = {
|
|
84
81
|
withCredentials: true
|
85
82
|
});
|
86
83
|
|
87
|
-
axios.interceptors.response.eject(productNotFoundInterceptor);
|
88
84
|
return response;
|
89
85
|
},
|
90
86
|
|
@@ -136,9 +132,11 @@ const ProductData = {
|
|
136
132
|
let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
|
137
133
|
|
138
134
|
|
139
|
-
const { eventName, eventLabels, computedPrice, defaultProductPrice } = this.getEqProductPromotions(eqVariant);
|
135
|
+
const { eventName, eventLabels, computedPrice, defaultProductPrice, CVPrice, PVPrice } = this.getEqProductPromotions(eqVariant);
|
140
136
|
const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
|
141
137
|
const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
|
138
|
+
const productCVPrice = eventName ? CVPrice : eqVariant.priceFacets.CV;
|
139
|
+
const productPVPrice = eventName ? PVPrice : eqVariant.priceFacets.PV;
|
142
140
|
|
143
141
|
return {
|
144
142
|
"sku": eqVariant.identifier,
|
@@ -245,8 +243,8 @@ const ProductData = {
|
|
245
243
|
"availableQuantity": eqVariant.inventoryProperties.atpQty,
|
246
244
|
"maxQuantity": 999,
|
247
245
|
"points": "",
|
248
|
-
"cv":
|
249
|
-
"pv":
|
246
|
+
"cv": productCVPrice,
|
247
|
+
"pv": productPVPrice,
|
250
248
|
"priceType": "WRTL",
|
251
249
|
"price": discountedPrice,
|
252
250
|
"priceMap": {
|
@@ -259,14 +257,14 @@ const ProductData = {
|
|
259
257
|
"WHL": eqVariant.priceFacets["Wholesale Price"]
|
260
258
|
},
|
261
259
|
"cvMap": {
|
262
|
-
"WWHL":
|
263
|
-
"WADW":
|
264
|
-
"WHL":
|
260
|
+
"WWHL": productCVPrice,
|
261
|
+
"WADW": productCVPrice,
|
262
|
+
"WHL": productCVPrice
|
265
263
|
},
|
266
264
|
"pvMap": {
|
267
|
-
"WWHL":
|
268
|
-
"WADW":
|
269
|
-
"WHL":
|
265
|
+
"WWHL": productPVPrice,
|
266
|
+
"WADW": productPVPrice,
|
267
|
+
"WHL": productPVPrice
|
270
268
|
},
|
271
269
|
"orderTypes": this._setOrderType(eqVariant.properties),
|
272
270
|
"custTypes": this.switchCustType(eqVariant.properties.customerTypes),
|
@@ -299,7 +297,8 @@ const ProductData = {
|
|
299
297
|
},
|
300
298
|
"restrictedMarkets": [],
|
301
299
|
"addOns": [],
|
302
|
-
"equinoxProductId": eqVariant.identifier
|
300
|
+
"equinoxProductId": eqVariant.identifier,
|
301
|
+
"properties": eqVariant.properties
|
303
302
|
};
|
304
303
|
},
|
305
304
|
|
@@ -323,6 +322,16 @@ const ProductData = {
|
|
323
322
|
const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
|
324
323
|
? product.totalValue.priceAfterDiscount
|
325
324
|
: 0;
|
325
|
+
|
326
|
+
let CVPrice = 0,
|
327
|
+
PVPrice = 0;
|
328
|
+
|
329
|
+
if (product.totalValue && product.totalValue.priceFacets) {
|
330
|
+
const productPriceFacets = product.totalValue.priceFacets;
|
331
|
+
CVPrice = productPriceFacets.CV && productPriceFacets.CV.CVAfterDiscount ? productPriceFacets.CV.CVAfterDiscount : 0;
|
332
|
+
PVPrice = productPriceFacets.PV && productPriceFacets.PV.PVAfterDiscount ? productPriceFacets.PV.PVAfterDiscount : 0;
|
333
|
+
}
|
334
|
+
|
326
335
|
let eventName = "";
|
327
336
|
const eventLabels = [];
|
328
337
|
|
@@ -336,17 +345,19 @@ const ProductData = {
|
|
336
345
|
eventLabels: eventLabels.join(','),
|
337
346
|
defaultProductPrice,
|
338
347
|
computedPrice,
|
339
|
-
eventName
|
348
|
+
eventName,
|
349
|
+
CVPrice,
|
350
|
+
PVPrice
|
340
351
|
}
|
341
352
|
},
|
342
353
|
|
343
354
|
eqProductMapper: async function (productDataResponse, skus) {
|
344
355
|
let count = 0;
|
345
|
-
let variants = {};
|
346
356
|
const products = [];
|
347
357
|
|
348
358
|
for (const productData of productDataResponse) {
|
349
359
|
try {
|
360
|
+
let variants = {};
|
350
361
|
let product = (productData.type && productData.type === "kit") ? productData : productData.sku[count];
|
351
362
|
let imageURL = product.properties.imageURL ? product.properties.imageURL : '';
|
352
363
|
let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
|
@@ -364,10 +375,14 @@ const ProductData = {
|
|
364
375
|
eventName,
|
365
376
|
eventLabels,
|
366
377
|
computedPrice,
|
367
|
-
defaultProductPrice
|
378
|
+
defaultProductPrice,
|
379
|
+
CVPrice,
|
380
|
+
PVPrice
|
368
381
|
} = this.getEqProductPromotions(product);
|
369
382
|
const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
|
370
383
|
const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
|
384
|
+
const productCVPrice = eventName ? CVPrice : product.priceFacets.CV;
|
385
|
+
const productPVPrice = eventName ? PVPrice : product.priceFacets.PV;
|
371
386
|
|
372
387
|
product.childSkus = await this.fetchChildSkus(product);
|
373
388
|
product.availableQuantity = mapAvailableQuantity(product);
|
@@ -406,8 +421,8 @@ const ProductData = {
|
|
406
421
|
"scanQualified": productData.properties.scanQualifiedCount,
|
407
422
|
"maxQuantity": 999,
|
408
423
|
"points": "",
|
409
|
-
"cv":
|
410
|
-
"pv":
|
424
|
+
"cv": productCVPrice,
|
425
|
+
"pv": productPVPrice,
|
411
426
|
"priceType": "WRTL",
|
412
427
|
"price": discountedPrice,
|
413
428
|
"priceMap": {
|
@@ -420,14 +435,14 @@ const ProductData = {
|
|
420
435
|
"WWHL": product.priceFacets["Wholesale Price"]
|
421
436
|
},
|
422
437
|
"cvMap": {
|
423
|
-
"WWHL":
|
424
|
-
"WADW":
|
425
|
-
"WHL":
|
438
|
+
"WWHL": productCVPrice,
|
439
|
+
"WADW": productCVPrice,
|
440
|
+
"WHL": productCVPrice
|
426
441
|
},
|
427
442
|
"pvMap": {
|
428
|
-
"WWHL":
|
429
|
-
"WADW":
|
430
|
-
"WHL":
|
443
|
+
"WWHL": productPVPrice,
|
444
|
+
"WADW": productPVPrice,
|
445
|
+
"WHL": productPVPrice
|
431
446
|
},
|
432
447
|
"orderTypes": this._setOrderType(product.properties),
|
433
448
|
"custTypes": this.switchCustType(product.properties.customerTypes),
|
@@ -462,7 +477,8 @@ const ProductData = {
|
|
462
477
|
"restrictedMarkets": [],
|
463
478
|
"addOns": [],
|
464
479
|
"inventory": product.inventory || "", //inventory label
|
465
|
-
"equinoxProductId": productData.identifier
|
480
|
+
"equinoxProductId": productData.identifier,
|
481
|
+
"properties": product.properties
|
466
482
|
};
|
467
483
|
|
468
484
|
products.push(new Product(product));
|
@@ -1,49 +0,0 @@
|
|
1
|
-
// httpStatus codes
|
2
|
-
const httpStatus = { notFound: 404 };
|
3
|
-
|
4
|
-
/**
|
5
|
-
* productNotFound returns a model "ProductNotFound" when the status code is Not Found.
|
6
|
-
* Note: Do not polute this file. Create a new file for new interceptor.
|
7
|
-
*
|
8
|
-
* @param {import('axios').AxiosError} error
|
9
|
-
* @returns {import('../').EquinoxResponse}
|
10
|
-
*/
|
11
|
-
function productNotFound(error) {
|
12
|
-
const segments = 'catalogs/search';
|
13
|
-
const { config, response } = error;
|
14
|
-
|
15
|
-
if (response.status === httpStatus.notFound && config.url.includes(segments)) {
|
16
|
-
const params = new URLSearchParams(config.url);
|
17
|
-
const filterParam = Array.from(params.values())[0];
|
18
|
-
const sku = getSKU(filterParam);
|
19
|
-
|
20
|
-
if (sku !== null) {
|
21
|
-
return {
|
22
|
-
product: {
|
23
|
-
sku
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
console.error('Unable to detect SKU from the given parameter', filterParam);
|
29
|
-
}
|
30
|
-
|
31
|
-
return Promise.reject(error);
|
32
|
-
}
|
33
|
-
|
34
|
-
/**
|
35
|
-
* getSKU returns the SKU from the given parameter.
|
36
|
-
* @param {string} param '\\''index_key_productId="02010489" OR index_key_skuId="02010489"'''
|
37
|
-
* @returns {string|null} SKU
|
38
|
-
*/
|
39
|
-
function getSKU(param) {
|
40
|
-
const result = param.match(/\d{8}/);
|
41
|
-
|
42
|
-
if (result === null) {
|
43
|
-
return null;
|
44
|
-
}
|
45
|
-
|
46
|
-
return result[0];
|
47
|
-
}
|
48
|
-
|
49
|
-
module.exports = productNotFound;
|
File without changes
|