@nuskin/ns-product-lib 2.7.0-cx24-3682.6 → 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 CHANGED
@@ -1,46 +1,30 @@
1
- # [2.7.0-cx24-3682.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.5...v2.7.0-cx24-3682.6) (2023-03-25)
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
- * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([13f2b76](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/13f2b76990dd2e4f4226367332212dcc7bd19977)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
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
- # [2.7.0-cx24-3682.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.4...v2.7.0-cx24-3682.5) (2023-03-25)
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
- ### New
12
-
13
- * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([588161d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/588161d54fa2e97f6bee2fe33523f3f1bdcb1ed2)), 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.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.3...v2.7.0-cx24-3682.4) (2023-03-24)
16
-
17
-
18
- ### New
19
-
20
- * 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)
21
-
22
- # [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)
23
-
24
-
25
- ### New
11
+ ### Fix
26
12
 
27
- * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([3ce010e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3ce010e162034d2cc49619f553baf7b8b7fcd4e0)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
13
+ * Fix drop down variants Cx24 3377 ([262328e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/262328e617b87d6dbf44b1393fdffaa10d8de13d))
28
14
 
29
- # [2.7.0-cx24-3682.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.1...v2.7.0-cx24-3682.2) (2023-03-24)
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)
30
16
 
31
17
 
32
- ### New
18
+ ### Update
33
19
 
34
- * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([219fbd5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/219fbd59b96ed9cbbc3ea94a24d886f0e8ca563f)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
35
- * 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)
36
- * 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))
37
21
 
38
- # [2.7.0-cx24-3682.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1...v2.7.0-cx24-3682.1) (2023-03-24)
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)
39
23
 
40
24
 
41
- ### New
25
+ ### Fix
42
26
 
43
- * MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([99cc11a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/99cc11a7a274d97c03efc0a4bcdd0e03eb7b552a)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
27
+ * Show dropdown for variants ([85cdf69](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/85cdf69cc2bbf6700ec5c9bcacc7222cf2ddf674))
44
28
 
45
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)
46
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.7.0-cx24-3682.6",
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.5",
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
@@ -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": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
249
- "pv": eqVariant.priceFacets.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": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
263
- "WADW": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
264
- "WHL": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : ''
260
+ "WWHL": productCVPrice,
261
+ "WADW": productCVPrice,
262
+ "WHL": productCVPrice
265
263
  },
266
264
  "pvMap": {
267
- "WWHL": eqVariant.priceFacets.PV,
268
- "WADW": eqVariant.priceFacets.PV,
269
- "WHL": eqVariant.priceFacets.PV
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": (product.priceFacets.CV) ? product.priceFacets.CV : '',
410
- "pv": product.priceFacets.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": (product.priceFacets.CV) ? product.priceFacets.CV : '',
424
- "WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
425
- "WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
438
+ "WWHL": productCVPrice,
439
+ "WADW": productCVPrice,
440
+ "WHL": productCVPrice
426
441
  },
427
442
  "pvMap": {
428
- "WWHL": product.priceFacets.PV,
429
- "WADW": product.priceFacets.PV,
430
- "WHL": product.priceFacets.PV
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,5 +0,0 @@
1
- const productNotFound = require('./productNotFound');
2
-
3
- module.exports = {
4
- productNotFoundInterceptor: productNotFound
5
- }
@@ -1,51 +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('axios').AxiosResponse<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
- data: {
23
- product: {
24
- sku
25
- }
26
- }
27
- }
28
- }
29
-
30
- console.error('Unable to detect SKU from the given parameter', filterParam);
31
- }
32
-
33
- return Promise.reject(error);
34
- }
35
-
36
- /**
37
- * getSKU returns the SKU from the given parameter.
38
- * @param {string} param '\\''index_key_productId="02010489" OR index_key_skuId="02010489"'''
39
- * @returns {string|null} SKU
40
- */
41
- function getSKU(param) {
42
- const result = param.match(/\d{8}/);
43
-
44
- if (result === null) {
45
- return null;
46
- }
47
-
48
- return result[0];
49
- }
50
-
51
- module.exports = productNotFound;
File without changes