@nuskin/ns-product-lib 2.19.0 → 2.19.1-cx24-70222.2
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 +8 -3
package/package.json
CHANGED
package/src/graph-ql/product.js
CHANGED
@@ -76,6 +76,7 @@ async function getProducts(ids, market, locale, config) {
|
|
76
76
|
null, 1, okta,
|
77
77
|
config.graphqlUrl.includes('test') ? 'test' : config.graphqlUrl.includes('dev') ? 'dev' : 'prod'
|
78
78
|
);
|
79
|
+
console.log(ids)
|
79
80
|
if (data && data.products) {
|
80
81
|
const mappedProducts = mapSkusToProducts(ids,data.products);
|
81
82
|
//use to get default variant based on requested sku
|
@@ -106,14 +107,17 @@ async function getProducts(ids, market, locale, config) {
|
|
106
107
|
* @param {any} products
|
107
108
|
*/
|
108
109
|
|
109
|
-
function mapSkusToProducts(skus, products){
|
110
|
+
function mapSkusToProducts(skus , products){
|
111
|
+
let newProducts = products.filter((n) => {
|
112
|
+
return n.id != null
|
113
|
+
})
|
110
114
|
const productsData = [];
|
111
115
|
if (products && products.length) {
|
112
116
|
skus.forEach((sku)=>{
|
113
|
-
const matchedProducts =
|
117
|
+
const matchedProducts = newProducts.filter((product)=>{
|
114
118
|
let matched = false;
|
115
119
|
if(product.id) {matched = product.id === sku;}
|
116
|
-
if(product.variants
|
120
|
+
if(product.variants.length){
|
117
121
|
product.variants.forEach((variant)=>{
|
118
122
|
matched |= variant.sku === sku;
|
119
123
|
});
|
@@ -129,6 +133,7 @@ function mapSkusToProducts(skus, products){
|
|
129
133
|
|
130
134
|
}
|
131
135
|
|
136
|
+
|
132
137
|
/**
|
133
138
|
*
|
134
139
|
* Map product data to be product card consumable structure *
|