@nuskin/ns-product-lib 2.18.0 → 2.19.1-cx24-70222.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.18.0",
3
+ "version": "2.19.1-cx24-70222.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": {
@@ -22,7 +22,7 @@
22
22
  "@nuskin/configuration-sdk": "2.3.2",
23
23
  "@nuskin/ns-common-lib": "1.4.7",
24
24
  "@nuskin/ns-util": "4.5.4",
25
- "@nuskin/product-lib": "2.2.0",
25
+ "@nuskin/product-lib": "2.2.1",
26
26
  "axios": "1.6.7",
27
27
  "axios-mock-adapter": "1.21.2",
28
28
  "eslint": "^8.56.0",
@@ -106,14 +106,21 @@ async function getProducts(ids, market, locale, config) {
106
106
  * @param {any} products
107
107
  */
108
108
 
109
- function mapSkusToProducts(skus, products){
109
+ function mapSkusToProducts(skus , products){
110
+ let newProducts = products.data.productsById.products.filter((n) => {
111
+ return n.id != null
112
+ })
110
113
  const productsData = [];
111
- if (products && products.length) {
114
+ if (products &&
115
+ products.data &&
116
+ products.data.productsById &&
117
+ products.data.productsById.products &&
118
+ products.data.productsById.products.length) {
112
119
  skus.forEach((sku)=>{
113
- const matchedProducts = products.filter((product)=>{
120
+ const matchedProducts = newProducts.filter((product)=>{
114
121
  let matched = false;
115
122
  if(product.id) {matched = product.id === sku;}
116
- if(product.variants && product.variants.length){
123
+ if(product.variants.length){
117
124
  product.variants.forEach((variant)=>{
118
125
  matched |= variant.sku === sku;
119
126
  });
@@ -129,6 +136,7 @@ function mapSkusToProducts(skus, products){
129
136
 
130
137
  }
131
138
 
139
+
132
140
  /**
133
141
  *
134
142
  * Map product data to be product card consumable structure *
@@ -551,8 +559,11 @@ function mapPromos(product) {
551
559
  if ((product.price.retailSales !== null && product.price.retailSales >= 0) || (product.price.wholesaleSales !== null && product.price.wholesaleSales >= 0)) {
552
560
  if (product.pricingJson) {
553
561
  const parsedPricing = JSON.parse(product.pricingJson)
554
- const promotion = parsedPricing.promotion
562
+ let promotion = parsedPricing.promotion
555
563
  if (promotion && promotion.length) {
564
+ if (promotion.length > 1) {
565
+ promotion = promotion.filter(p=>p.message !== 'Bundle discount')
566
+ }
556
567
  const offerId = promotion[0].offerId || 'EQPROMO'
557
568
  return {
558
569
  priceMap: {[`${offerId}-WRTL`]: product.price.retailSales, [`${offerId}-WWHL`]: product.price.wholesaleSales},