@nuskin/ns-product-lib 2.4.1 → 2.4.2-CX24.2.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.4.2-CX24.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.4.2-CX24.2.1) (2022-11-07)
2
+
3
+
4
+ ### Fix
5
+
6
+ * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([82611ca](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/82611cab93c990ed1ce05690feb9d00967090dea))
7
+
1
8
  ## [2.4.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.0...v2.4.1) (2022-11-06)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.4.1",
3
+ "version": "2.4.2-CX24.2.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": {
@@ -43,7 +43,7 @@ const ProductData = {
43
43
  });
44
44
 
45
45
  if (response.data.product) {
46
- return this.eqProductMapper(response.data.product);
46
+ return this.eqProductMapper(response.data.product, skus);
47
47
  }
48
48
 
49
49
  return {
@@ -210,7 +210,7 @@ const ProductData = {
210
210
  };
211
211
  },
212
212
 
213
- eqProductMapper: function (productDataResponse) {
213
+ eqProductMapper: function (productDataResponse, skus) {
214
214
  let prod = [];
215
215
  let count = 0;
216
216
  let variants = {};
@@ -344,7 +344,7 @@ const ProductData = {
344
344
  })
345
345
 
346
346
  let data = {
347
- products: prodArr,
347
+ products: this._sortProductsBySku(skus, prodArr),
348
348
  count: productDataResponse.length
349
349
  };
350
350
  return {
@@ -395,6 +395,24 @@ const ProductData = {
395
395
  if (custType.includes('Preferred Customer/Member'))
396
396
  newCustType.push(30)
397
397
  return newCustType.toString()
398
+ },
399
+
400
+ /**
401
+ * Sorts the product by sku
402
+ * @param {Array} skus - the skus arrangment which the sorting will base out of
403
+ * @param {Array} products - this products to be sorted
404
+ */
405
+
406
+ _sortProductsBySku: function (skus, products) {
407
+
408
+ if(!skus || !products || products.length === 1) {
409
+ return products
410
+ }
411
+
412
+ return products.sort(function (a, b) {
413
+ return skus.indexOf(a.sku) - skus.indexOf(b.sku);
414
+ });
415
+
398
416
  }
399
417
  }
400
418