@nuskin/ns-product-lib 2.13.0-cx24-5107.17 → 2.13.0-cx24-51071125.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.13.0-cx24-5107.17",
3
+ "version": "2.13.0-cx24-51071125.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": {
@@ -16,7 +16,7 @@ const defaultPayload = {
16
16
  */
17
17
  async function graphQlHttpRequest(payload, config) {
18
18
  const url = config.graphqlUrl
19
- return await axios.request({
19
+ return await axios.request({
20
20
  method: 'post',
21
21
  url: url,
22
22
  data: payload,
@@ -55,7 +55,7 @@ async function getProduct(id, market, locale, config) {
55
55
  }
56
56
 
57
57
  } catch (e) {
58
- console.log(`Unable to fetch product detail for SKU ${id}`);
58
+ console.log(`Unable to fetch product detail for SKU ${id}` + e);
59
59
  }
60
60
 
61
61
  return {
@@ -184,7 +184,7 @@ function mapProduct(product, market, locale, config) {
184
184
  skuId: product.id,
185
185
  type: kitBundleProducts.type.toUpperCase()
186
186
  },
187
- ...mapChildSKU(kitBundleProducts)
187
+ ...mapChildSKU(kitBundleProducts, product.id)
188
188
  ];
189
189
  }
190
190
 
@@ -286,13 +286,25 @@ function mapVariants(product) {
286
286
  * @param {*} kitBundleProducts
287
287
  * @returns {array} kitBundleProducts
288
288
  */
289
- function mapChildSKU(kitBundleProducts) {
289
+ function mapChildSKU(kitBundleProducts, productSku) {
290
290
  if (!kitBundleProducts || !kitBundleProducts.kitProducts) {
291
291
  return [];
292
292
  }
293
-
293
+ let personalOffer = JSON.parse(sessionStorage.getItem('personalOffer'))
294
+ let productWithVariant;
295
+ if (personalOffer && personalOffer.active) {
296
+ productWithVariant = personalOffer.products.filter((sku) =>
297
+ sku.type === 'bundle' && sku.variantSelected !== null && sku.sku === productSku
298
+ )
299
+ }
294
300
  return kitBundleProducts.kitProducts.map((kitProduct) => {
295
301
  const { product } = kitProduct;
302
+ if (personalOffer && personalOffer.active) {
303
+ const variantSelected = kitProduct.product.variants.filter(v =>
304
+ v.sku === productWithVariant[0].variantSelected[kitProduct.product.id]
305
+ )
306
+ console.log(variantSelected)
307
+ }
296
308
  const defaultVariant = product.variants[0];
297
309
  return {
298
310
  productId: product.id,