@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 +1 -1
- package/src/graph-ql/product.js +12 -4
package/package.json
CHANGED
package/src/graph-ql/product.js
CHANGED
@@ -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 &&
|
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 =
|
120
|
+
const matchedProducts = newProducts.filter((product)=>{
|
114
121
|
let matched = false;
|
115
122
|
if(product.id) {matched = product.id === sku;}
|
116
|
-
if(product.variants
|
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 *
|