@nuskin/ns-product-lib 2.15.0 → 2.15.2-cx24-6768.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.15.0",
3
+ "version": "2.15.2-cx24-6768.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": {
@@ -21,7 +21,7 @@
21
21
  "devDependencies": {
22
22
  "@nuskin/configuration-sdk": "2.3.2",
23
23
  "@nuskin/ns-common-lib": "1.4.7",
24
- "@nuskin/ns-util": "4.5.3",
24
+ "@nuskin/ns-util": "4.5.4",
25
25
  "axios": ">=1.6.5",
26
26
  "axios-mock-adapter": "1.21.2",
27
27
  "eslint": "^8.56.0",
@@ -7,7 +7,7 @@
7
7
  * @returns {number}
8
8
  */
9
9
  function backOrderDate(product) {
10
- if (product.inventoryProperties && product.inventoryProperties.expectedBackOrderAvailabilityDate) {
10
+ if (product.inventoryProperties && Object.hasOwnProperty.call(product.inventoryProperties, 'expectedBackOrderAvailabilityDate')) {
11
11
  return product.inventoryProperties.expectedBackOrderAvailabilityDate;
12
12
  }
13
13
 
@@ -351,19 +351,23 @@ function mapChildSKU(kitBundleProducts) {
351
351
 
352
352
  return kitBundleProducts.kitProducts.map((kitProduct) => {
353
353
  const { product } = kitProduct;
354
- const defaultVariant = product.variants[0];
355
- return {
356
- productId: product.id,
357
- skuId: defaultVariant.sku,
358
- type: 'MANDATORY',
359
- skuQuantity: kitProduct.quantity,
360
- availableChannels: Array.isArray(kitBundleProducts.availableChannels) ? kitBundleProducts.availableChannels.join(',') : kitBundleProducts.availableChannels,
361
- inventory: {
362
- atpQty: defaultVariant.availableQuantity,
363
- backOrdered: defaultVariant.status.isBackordered,
364
- backOrderedQty: defaultVariant.availableQuantity
365
- }
354
+ const arr1 = []
355
+ for (const variant of product.variants) {
356
+ arr1.push({
357
+ productId: product.id,
358
+ skuId: variant.sku,
359
+ type: 'MANDATORY',
360
+ skuQuantity: variant.availableQuantity,
361
+ // eslint-disable-next-line max-len
362
+ availableChannels: Array.isArray(kitBundleProducts.availableChannels) ? kitBundleProducts.availableChannels.join(',') : kitBundleProducts.availableChannels,
363
+ inventory: {
364
+ atpQty: variant.availableQuantity,
365
+ backOrdered: variant.status.isBackordered,
366
+ backOrderedQty: variant.availableQuantity
367
+ }
368
+ })
366
369
  }
370
+ return Object.assign({}, arr1)
367
371
  });
368
372
  }
369
373
 
@@ -25,12 +25,12 @@ const ProductData = {
25
25
 
26
26
  const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
27
27
  if (config.active) {
28
- return (config.MySite_graphql_active_list.includes(market)) ?
29
- await getProduct(skus[0], market, locale, config) :
28
+ return (config.MySite_graphql_active_list.includes(market)) ?
29
+ await getProduct(skus[0], market, locale, config) :
30
30
  await this.getProductFromEquinox(skus, localeMarket, config)
31
31
  } else {
32
- return (config.MySite_graphql_active_list.includes(market)) ?
33
- await getProduct(skus[0], market, locale, config) :
32
+ return (config.MySite_graphql_active_list.includes(market)) ?
33
+ await getProduct(skus[0], market, locale, config) :
34
34
  await this.getProductFromLegacy(skus, localeMarket);
35
35
  }
36
36
 
@@ -150,10 +150,8 @@ const ProductData = {
150
150
  * @returns {number} qty
151
151
  */
152
152
  getAvailableQty: function (inventory) {
153
- if (!inventory || (!Object.prototype.hasOwnProperty.call(inventory, 'backOrdered')
154
- || !Object.prototype.hasOwnProperty.call(inventory, 'atpQty')
155
- || !Object.prototype.hasOwnProperty.call(inventory, 'backOrderedQty'))
156
- ) {
153
+ if (!inventory || !Object.hasOwnProperty.call(inventory, 'backOrdered')
154
+ || !Object.hasOwnProperty.call(inventory, 'atpQty') || !Object.hasOwnProperty.call(inventory, 'backOrderedQty')) {
157
155
  return 0;
158
156
  }
159
157