@nuskin/ns-product-lib 2.19.7-td-1017.3 → 2.19.8-gms-10644.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/graph-ql/product.js +21 -22
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.19.
|
3
|
+
"version": "2.19.8-gms-10644.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": "3.0.0",
|
23
23
|
"@nuskin/ns-common-lib": "1.4.7",
|
24
24
|
"@nuskin/ns-util": "4.5.4",
|
25
|
-
"@nuskin/product-lib": "2.
|
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",
|
package/src/graph-ql/product.js
CHANGED
@@ -72,8 +72,8 @@ async function getProducts(ids, market, locale, config) {
|
|
72
72
|
|
73
73
|
try {
|
74
74
|
const data = await productLib.getProductsById(
|
75
|
-
ids, market, locale,
|
76
|
-
null, 1, okta,
|
75
|
+
ids, market, locale,
|
76
|
+
null, 1, okta,
|
77
77
|
config.graphqlUrl.includes('test') ? 'test' : config.graphqlUrl.includes('dev') ? 'dev' : 'prod'
|
78
78
|
);
|
79
79
|
if (data && data.products) {
|
@@ -248,16 +248,16 @@ function mapPricingJson(productDetail, kitOrVariant, isContentStack) {
|
|
248
248
|
// eslint-disable-next-line no-unused-vars
|
249
249
|
function mapProduct(product, market, locale, config) {
|
250
250
|
const kitBundleProducts = product.bundle;
|
251
|
+
|
251
252
|
//serves as parent
|
252
253
|
const defaultVariant = !kitBundleProducts ? product.variants.find(v => v.sku === config.sku) : null
|
253
|
-
const productImages = mapProductImages(product)
|
254
254
|
const kitOrVariant = !kitBundleProducts ? defaultVariant : kitBundleProducts
|
255
255
|
const productOrVariant = !kitBundleProducts ? defaultVariant : product
|
256
|
+
const productImages = mapProductImages(productOrVariant)
|
256
257
|
const pricing = kitOrVariant.price
|
257
258
|
const points = kitOrVariant.points
|
258
259
|
const isBackOrdered = kitOrVariant.status.inventory === 'backordered'
|
259
260
|
const promoData = mapPromos(kitOrVariant)
|
260
|
-
const productionBom = product.bundle && product.bundle.isProductionBom ? product.bundle.isProductionBom : false;
|
261
261
|
|
262
262
|
const productDetail = {
|
263
263
|
"sku": !kitBundleProducts ? defaultVariant.sku : product.id,
|
@@ -277,8 +277,8 @@ function mapProduct(product, market, locale, config) {
|
|
277
277
|
"availableQuantity": isBackOrdered ? kitOrVariant.backorderQuantity : kitOrVariant.atpQuantity,
|
278
278
|
"maxQuantity": kitOrVariant.maxQuantity,
|
279
279
|
"points": "",
|
280
|
-
"cv": points.wholesale ? points.wholesale.cv : 0,
|
281
|
-
"pv": points.wholesale ? points.wholesale.pv : 0,
|
280
|
+
"cv": points && points.wholesale ? points.wholesale.cv : 0,
|
281
|
+
"pv": points && points.wholesale ? points.wholesale.pv : 0,
|
282
282
|
"priceType": "WRTL",
|
283
283
|
"price": pricing.retail,
|
284
284
|
"priceMap": {
|
@@ -295,15 +295,15 @@ function mapProduct(product, market, locale, config) {
|
|
295
295
|
},
|
296
296
|
"cvMap": {
|
297
297
|
...promoData.cvMap,
|
298
|
-
"WWHL": points.wholesale ? points.wholesale.cv : 0,
|
299
|
-
"WADW": points.subscription ? points.subscription.cv : 0,
|
300
|
-
"WHL": points.wholesale ? points.wholesale.cv : 0
|
298
|
+
"WWHL": points && points.wholesale ? points.wholesale.cv : 0,
|
299
|
+
"WADW": points && points.subscription ? points.subscription.cv : 0,
|
300
|
+
"WHL": points && points.wholesale ? points.wholesale.cv : 0
|
301
301
|
},
|
302
302
|
"pvMap": {
|
303
303
|
...promoData.pvMap,
|
304
|
-
"WWHL": points.wholesale ? points.wholesale.pv : 0,
|
305
|
-
"WADW": points.subscription ? points.subscription.pv : 0,
|
306
|
-
"WHL": points.wholesale ? points.wholesale.pv : 0
|
304
|
+
"WWHL": points && points.wholesale ? points.wholesale.pv : 0,
|
305
|
+
"WADW": points && points.subscription ? points.subscription.pv : 0,
|
306
|
+
"WHL": points && points.wholesale ? points.wholesale.pv : 0
|
307
307
|
},
|
308
308
|
"orderTypes": mapOrderTypes(kitOrVariant.availableChannels, kitOrVariant.purchaseTypes),
|
309
309
|
"custTypes": mapCustomerTypes(kitOrVariant.customerTypes),
|
@@ -328,8 +328,7 @@ function mapProduct(product, market, locale, config) {
|
|
328
328
|
"properties": {
|
329
329
|
isBackOrdered: isBackOrdered,
|
330
330
|
inventoryStatus: isBackOrdered ? 'BACKORDER' : 'IN STOCK',
|
331
|
-
productStatus: mapProductStatus(kitOrVariant.status.status)
|
332
|
-
productionBom: productionBom
|
331
|
+
productStatus: mapProductStatus(kitOrVariant.status.status)
|
333
332
|
}
|
334
333
|
}
|
335
334
|
|
@@ -400,8 +399,8 @@ function mapVariants(product, isContentStack) {
|
|
400
399
|
"availableQuantity": variant.availableQuantity,
|
401
400
|
"maxQuantity": variant.maxQuantity,
|
402
401
|
"points": "",
|
403
|
-
"cv": points.wholesale ? points.wholesale.cv : 0,
|
404
|
-
"pv": points.wholesale ? points.wholesale.pv : 0,
|
402
|
+
"cv": points && points.wholesale ? points.wholesale.cv : 0,
|
403
|
+
"pv": points && points.wholesale ? points.wholesale.pv : 0,
|
405
404
|
"priceType": "WRTL",
|
406
405
|
"price": pricing.retail,
|
407
406
|
"priceMap": {
|
@@ -418,15 +417,15 @@ function mapVariants(product, isContentStack) {
|
|
418
417
|
},
|
419
418
|
"cvMap": {
|
420
419
|
...promoData.cvMap,
|
421
|
-
"WWHL": points.wholesale ? points.wholesale.cv : 0,
|
422
|
-
"WADW": points.subscription ? points.subscription.cv : 0,
|
423
|
-
"WHL": points.wholesale ? points.wholesale.cv : 0
|
420
|
+
"WWHL": points && points.wholesale ? points.wholesale.cv : 0,
|
421
|
+
"WADW": points && points.subscription ? points.subscription.cv : 0,
|
422
|
+
"WHL": points && points.wholesale ? points.wholesale.cv : 0
|
424
423
|
},
|
425
424
|
"pvMap": {
|
426
425
|
...promoData.pvMap,
|
427
|
-
"WWHL": points.wholesale ? points.wholesale.pv : 0,
|
428
|
-
"WADW": points.subscription ? points.subscription.pv : 0,
|
429
|
-
"WHL": points.wholesale ? points.wholesale.pv : 0
|
426
|
+
"WWHL": points && points.wholesale ? points.wholesale.pv : 0,
|
427
|
+
"WADW": points && points.subscription ? points.subscription.pv : 0,
|
428
|
+
"WHL": points && points.wholesale ? points.wholesale.pv : 0
|
430
429
|
},
|
431
430
|
"orderTypes": mapOrderTypes(variant.availableChannels, variant.purchaseTypes),
|
432
431
|
"custTypes": mapCustomerTypes(variant.customerTypes),
|