@nuskin/ns-product-lib 2.7.0-cx24-337705.1 → 2.7.0-cx24-3682.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,24 +1,18 @@
1
- # [2.7.0-cx24-337705.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-337703.1...v2.7.0-cx24-337705.1) (2023-03-23)
1
+ # [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)
2
2
 
3
3
 
4
- ### Fix
5
-
6
- * Added override flag for equinox products ([d098245](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d098245007f453e33cae8fb574dad61fadfc1e5e))
7
- * Added override flag for equinox products ([2f4af3d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2f4af3d5f7fcfa14f23c9cd18eacfaaa9262e0a0))
8
-
9
- # [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)
10
-
11
-
12
- ### Update
4
+ ### New
13
5
 
14
- * Merge CX24-3563 changes to CX24-337703 ([9e6ca40](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9e6ca40c35252c24394351275a234e9847f70bfc))
6
+ * 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)
7
+ * 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)
8
+ * 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)
15
9
 
16
- ## [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)
10
+ # [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)
17
11
 
18
12
 
19
- ### Fix
13
+ ### New
20
14
 
21
- * Show dropdown for variants ([85cdf69](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/85cdf69cc2bbf6700ec5c9bcacc7222cf2ddf674))
15
+ * 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)
22
16
 
23
17
  ## [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)
24
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.7.0-cx24-337705.1",
3
+ "version": "2.7.0-cx24-3682.2",
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.7",
36
+ "@nuskin/ns-util": "4.2.5",
37
37
  "axios": "0.27.2",
38
38
  "qs": "6.11.0"
39
39
  },
@@ -0,0 +1,19 @@
1
+ /**
2
+ * productFoundInterceptor is executed when an equinox product is found
3
+ * @param {import('axios').AxiosResponse} response
4
+ */
5
+ function productFoundInterceptor(response) {
6
+ console.log('productFoundInterceptor', response);
7
+ return response;
8
+ }
9
+
10
+ /**
11
+ * productNotFoundInterceptor is called when an equinox product is not found
12
+ * @param {import('axios').AxiosError} error
13
+ */
14
+ function productNotFoundInterceptor(error) {
15
+ console.log('productNotFoundInterceptor', error);
16
+ return Promise.reject(error);
17
+ }
18
+
19
+ module.exports = { productFoundInterceptor, productNotFoundInterceptor };
File without changes
package/src/product.js CHANGED
@@ -325,15 +325,10 @@ const Product = function(productData) {
325
325
  return this.addCvWithType(csvKey, productStatus.csv[csvKey]);
326
326
  }, this);
327
327
  }
328
-
329
- //dont override orderTypes and childSkus when product came from equinox
330
- if(!this.equinoxProductId) {
331
- this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
332
- if(productStatus.childSkus) {
333
- this.childSkus = productStatus.childSkus;
334
- }
328
+ this.orderTypes = ProductUtils.mergeOrderTypes(this.orderTypes, productStatus.orderType);
329
+ if(productStatus.childSkus) {
330
+ this.childSkus = productStatus.childSkus;
335
331
  }
336
-
337
332
  this.setPriceAndPvFromType(priceType, null, option);
338
333
  modified = true;
339
334
  } else {
@@ -6,6 +6,10 @@ 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 {
10
+ productFoundInterceptor,
11
+ productNotFoundInterceptor
12
+ } = require('./equinox-helpers/interceptors/product');
9
13
 
10
14
  const productTypes = {
11
15
  kit: 'kit'
@@ -34,6 +38,7 @@ const ProductData = {
34
38
 
35
39
  getProductFromEquinox: async function (skus, locale, config) {
36
40
  const response = await this.searchEquinoxProduct(skus, locale, config);
41
+ console.log(response);
37
42
 
38
43
  if (response.data.product) {
39
44
  return await this.eqProductMapper(response.data.product, skus);
@@ -66,9 +71,11 @@ const ProductData = {
66
71
  }
67
72
 
68
73
  const filter = skuFilter.join(" OR ")
74
+ //axios.defaults.withCredentials = true;
69
75
 
70
76
  const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
71
77
  const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
78
+ axios.interceptors.response.use(productFoundInterceptor, productNotFoundInterceptor);
72
79
  const response = await axios.request({
73
80
  method: 'get',
74
81
  url: href,
@@ -81,6 +88,8 @@ const ProductData = {
81
88
  withCredentials: true
82
89
  });
83
90
 
91
+ axios.interceptors.response.eject(productFoundInterceptor);
92
+ axios.interceptors.response.eject(productNotFoundInterceptor);
84
93
  return response;
85
94
  },
86
95
 
@@ -132,11 +141,9 @@ const ProductData = {
132
141
  let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
133
142
 
134
143
 
135
- const { eventName, eventLabels, computedPrice, defaultProductPrice, CVPrice, PVPrice } = this.getEqProductPromotions(eqVariant);
144
+ const { eventName, eventLabels, computedPrice, defaultProductPrice } = this.getEqProductPromotions(eqVariant);
136
145
  const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
137
146
  const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
138
- const productCVPrice = eventName ? CVPrice : eqVariant.priceFacets.CV;
139
- const productPVPrice = eventName ? PVPrice : eqVariant.priceFacets.PV;
140
147
 
141
148
  return {
142
149
  "sku": eqVariant.identifier,
@@ -243,8 +250,8 @@ const ProductData = {
243
250
  "availableQuantity": eqVariant.inventoryProperties.atpQty,
244
251
  "maxQuantity": 999,
245
252
  "points": "",
246
- "cv": productCVPrice,
247
- "pv": productPVPrice,
253
+ "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
254
+ "pv": eqVariant.priceFacets.PV,
248
255
  "priceType": "WRTL",
249
256
  "price": discountedPrice,
250
257
  "priceMap": {
@@ -257,14 +264,14 @@ const ProductData = {
257
264
  "WHL": eqVariant.priceFacets["Wholesale Price"]
258
265
  },
259
266
  "cvMap": {
260
- "WWHL": productCVPrice,
261
- "WADW": productCVPrice,
262
- "WHL": productCVPrice
267
+ "WWHL": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
268
+ "WADW": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
269
+ "WHL": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : ''
263
270
  },
264
271
  "pvMap": {
265
- "WWHL": productPVPrice,
266
- "WADW": productPVPrice,
267
- "WHL": productPVPrice
272
+ "WWHL": eqVariant.priceFacets.PV,
273
+ "WADW": eqVariant.priceFacets.PV,
274
+ "WHL": eqVariant.priceFacets.PV
268
275
  },
269
276
  "orderTypes": this._setOrderType(eqVariant.properties),
270
277
  "custTypes": this.switchCustType(eqVariant.properties.customerTypes),
@@ -321,16 +328,6 @@ const ProductData = {
321
328
  const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
322
329
  ? product.totalValue.priceAfterDiscount
323
330
  : 0;
324
-
325
- let CVPrice = 0,
326
- PVPrice = 0;
327
-
328
- if(product.totalValue && product.totalValue.priceFacets) {
329
- const productPriceFacets = product.totalValue.priceFacets;
330
- CVPrice = productPriceFacets.CV && productPriceFacets.CV.CVAfterDiscount ? productPriceFacets.CV.CVAfterDiscount : 0;
331
- PVPrice = productPriceFacets.PV && productPriceFacets.PV.PVAfterDiscount ? productPriceFacets.PV.PVAfterDiscount : 0;
332
- }
333
-
334
331
  let eventName = "";
335
332
  const eventLabels = [];
336
333
 
@@ -344,19 +341,17 @@ const ProductData = {
344
341
  eventLabels: eventLabels.join(','),
345
342
  defaultProductPrice,
346
343
  computedPrice,
347
- eventName,
348
- CVPrice,
349
- PVPrice
344
+ eventName
350
345
  }
351
346
  },
352
347
 
353
348
  eqProductMapper: async function (productDataResponse, skus) {
354
349
  let count = 0;
350
+ let variants = {};
355
351
  const products = [];
356
352
 
357
353
  for (const productData of productDataResponse) {
358
354
  try {
359
- let variants = {};
360
355
  let product = (productData.type && productData.type === "kit") ? productData : productData.sku[count];
361
356
  let imageURL = product.properties.imageURL ? product.properties.imageURL : '';
362
357
  let thumbnailImage = imageURL ? imageURL + '?width=40' : ''
@@ -374,14 +369,10 @@ const ProductData = {
374
369
  eventName,
375
370
  eventLabels,
376
371
  computedPrice,
377
- defaultProductPrice,
378
- CVPrice,
379
- PVPrice
372
+ defaultProductPrice
380
373
  } = this.getEqProductPromotions(product);
381
374
  const productPrice = eventName ? defaultProductPrice : product.priceFacets["Regular Price"];
382
375
  const discountedPrice = eventName ? computedPrice : product.priceFacets["Regular Price"];
383
- const productCVPrice = eventName ? CVPrice : product.priceFacets.CV;
384
- const productPVPrice = eventName ? PVPrice : product.priceFacets.PV;
385
376
 
386
377
  product.childSkus = await this.fetchChildSkus(product);
387
378
  product.availableQuantity = mapAvailableQuantity(product);
@@ -420,8 +411,8 @@ const ProductData = {
420
411
  "scanQualified": productData.properties.scanQualifiedCount,
421
412
  "maxQuantity": 999,
422
413
  "points": "",
423
- "cv": productCVPrice,
424
- "pv": productPVPrice,
414
+ "cv": (product.priceFacets.CV) ? product.priceFacets.CV : '',
415
+ "pv": product.priceFacets.PV,
425
416
  "priceType": "WRTL",
426
417
  "price": discountedPrice,
427
418
  "priceMap": {
@@ -434,14 +425,14 @@ const ProductData = {
434
425
  "WWHL": product.priceFacets["Wholesale Price"]
435
426
  },
436
427
  "cvMap": {
437
- "WWHL": productCVPrice,
438
- "WADW": productCVPrice,
439
- "WHL": productCVPrice
428
+ "WWHL": (product.priceFacets.CV) ? product.priceFacets.CV : '',
429
+ "WADW": (product.priceFacets.CV) ? product.priceFacets.CV : '',
430
+ "WHL": (product.priceFacets.CV) ? product.priceFacets.CV : ''
440
431
  },
441
432
  "pvMap": {
442
- "WWHL": productPVPrice,
443
- "WADW": productPVPrice,
444
- "WHL": productPVPrice
433
+ "WWHL": product.priceFacets.PV,
434
+ "WADW": product.priceFacets.PV,
435
+ "WHL": product.priceFacets.PV
445
436
  },
446
437
  "orderTypes": this._setOrderType(product.properties),
447
438
  "custTypes": this.switchCustType(product.properties.customerTypes),