@nuskin/ns-product-lib 2.19.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.19.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": {
@@ -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 *