@nuskin/ns-product-lib 2.14.2 → 2.14.3-cx24-5962.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.14.2",
3
+ "version": "2.14.3-cx24-5962.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": {
@@ -202,8 +202,8 @@ function mapProduct(product, market, locale, config) {
202
202
  "groupOffer": false,
203
203
  "personalOffer": false,
204
204
  "savedEventName": '',
205
- "salesLabel": defaultVariant.salesLabel || defaultVariant.salesText,
206
- "eventName": defaultVariant.salesLabel || defaultVariant.salesText,
205
+ "salesLabel": mapPromos(defaultVariant, !!kitBundleProducts).message || '',
206
+ "eventName": mapPromos(defaultVariant, !!kitBundleProducts).offerId || '',
207
207
  "sizeWeight": '',
208
208
  "nettoWeight": "",
209
209
  "searchScore": 0,
@@ -506,4 +506,15 @@ function mapProductStatus(status) {
506
506
  return newStatus;
507
507
  }
508
508
 
509
+ function mapPromos(product, isKitBundle = false) {
510
+ if (isKitBundle) {
511
+ const { pricingJson } = product
512
+ const promotion = pricingJson.promotion
513
+ return (promotion && promotion.length >= 1) ? { message: promotion[0].message, offerId: promotion[0].offerId } : { message: '', offerId: '' }
514
+ } else {
515
+ return { message: product.salesLabel || product.salesText, offerId: product.salesLabel || product.salesText }
516
+ }
517
+
518
+ }
519
+
509
520
  module.exports = getProduct;
@@ -13,6 +13,7 @@ const getProductByIdQuery = `query getProduct($id: String!, $market: String, $la
13
13
  ...Product
14
14
  bundle {
15
15
  ...Kit
16
+ pricingJson
16
17
  __typename
17
18
  }
18
19
  __typename