@nuskin/ns-product-lib 2.19.1-cx24-70222.2 → 2.19.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 +3 -8
- package/src/product.js +3 -0
package/package.json
CHANGED
package/src/graph-ql/product.js
CHANGED
@@ -76,7 +76,6 @@ 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)
|
80
79
|
if (data && data.products) {
|
81
80
|
const mappedProducts = mapSkusToProducts(ids,data.products);
|
82
81
|
//use to get default variant based on requested sku
|
@@ -107,17 +106,14 @@ async function getProducts(ids, market, locale, config) {
|
|
107
106
|
* @param {any} products
|
108
107
|
*/
|
109
108
|
|
110
|
-
function mapSkusToProducts(skus
|
111
|
-
let newProducts = products.filter((n) => {
|
112
|
-
return n.id != null
|
113
|
-
})
|
109
|
+
function mapSkusToProducts(skus, products){
|
114
110
|
const productsData = [];
|
115
111
|
if (products && products.length) {
|
116
112
|
skus.forEach((sku)=>{
|
117
|
-
const matchedProducts =
|
113
|
+
const matchedProducts = products.filter((product)=>{
|
118
114
|
let matched = false;
|
119
115
|
if(product.id) {matched = product.id === sku;}
|
120
|
-
if(product.variants.length){
|
116
|
+
if(product.variants && product.variants.length){
|
121
117
|
product.variants.forEach((variant)=>{
|
122
118
|
matched |= variant.sku === sku;
|
123
119
|
});
|
@@ -133,7 +129,6 @@ function mapSkusToProducts(skus , products){
|
|
133
129
|
|
134
130
|
}
|
135
131
|
|
136
|
-
|
137
132
|
/**
|
138
133
|
*
|
139
134
|
* Map product data to be product card consumable structure *
|
package/src/product.js
CHANGED
@@ -31,6 +31,7 @@ const Product = function (productData) {
|
|
31
31
|
this.sizeWeight = "";
|
32
32
|
this.nettoWeight = "";
|
33
33
|
this.productLabels = {};
|
34
|
+
this.dangerousGoods = false;
|
34
35
|
this.count = "";
|
35
36
|
this.flavor = "";
|
36
37
|
this.shade = "";
|
@@ -514,6 +515,7 @@ const Product = function (productData) {
|
|
514
515
|
retData.scanQualified = this.scanQualified;
|
515
516
|
retData.availableQuantity = this.availableQuantity;
|
516
517
|
retData.maxQuantity = this.maxQuantity;
|
518
|
+
retData.dangerousGoods = this.dangerousGoods;
|
517
519
|
retData.points = this.points;
|
518
520
|
retData.cv = this.cv;
|
519
521
|
retData.pv = this.pv;
|
@@ -600,6 +602,7 @@ const Product = function (productData) {
|
|
600
602
|
this.shortDescr = data.shortDescr;
|
601
603
|
this.longDescr = data.longDescr;
|
602
604
|
this.isExclusive = isTrue(data.isExclusive);
|
605
|
+
this.dangerousGoods = data.dangerousGoods === true;
|
603
606
|
|
604
607
|
// WARNING: Browser Detection will need to be handled in the client
|
605
608
|
// if (!BrowserDetection.isEdge() && !BrowserDetection.isFirefox()) {
|