@nuskin/ns-product-lib 2.4.0 → 2.4.1-cx24-2612.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,11 @@
1
+ ## [2.4.1-cx24-2612.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.0...v2.4.1-cx24-2612.1) (2022-11-03)
2
+
3
+
4
+ ### Fix
5
+
6
+ * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([767efcd](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/767efcd821764a83212321707f1f1db64527e48e))
7
+ * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([bfbb4a4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bfbb4a4902faa5a17904e47d37aa935199a78d2e))
8
+
1
9
  # [2.4.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.3.0...v2.4.0) (2022-10-26)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.4.0",
3
+ "version": "2.4.1-cx24-2612.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": {
@@ -30,7 +30,6 @@ const ProductData = {
30
30
  axios.defaults.withCredentials = true;
31
31
 
32
32
  const url = await contentstack.getKongUrl() + `/orchestrationservices/storefront/catalogs/search/`;
33
- console.log("Dynamic URL", url)
34
33
  const href = `${url}?filter=${encodeURI(filter)}`;
35
34
  const response = await axios.request({
36
35
  method: 'get',
@@ -44,7 +43,7 @@ const ProductData = {
44
43
  });
45
44
 
46
45
  if (response.data.product) {
47
- return this.eqProductMapper(response.data.product);
46
+ return this.eqProductMapper(response.data.product, skus);
48
47
  }
49
48
 
50
49
  return {
@@ -211,7 +210,7 @@ const ProductData = {
211
210
  };
212
211
  },
213
212
 
214
- eqProductMapper: function (productDataResponse) {
213
+ eqProductMapper: function (productDataResponse, skus) {
215
214
  let prod = [];
216
215
  let count = 0;
217
216
  let variants = {};
@@ -345,7 +344,7 @@ const ProductData = {
345
344
  })
346
345
 
347
346
  let data = {
348
- products: prodArr,
347
+ products: this._sortProductsBySku(skus, prodArr),
349
348
  count: productDataResponse.length
350
349
  };
351
350
  return {
@@ -396,6 +395,26 @@ const ProductData = {
396
395
  if (custType.includes('Preferred Customer/Member'))
397
396
  newCustType.push(30)
398
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
+ const sortedProducts = products.sort(function (a, b) {
413
+ return skus.indexOf(a.sku) - skus.indexOf(b.sku);
414
+ });
415
+
416
+ return sortedProducts
417
+
399
418
  }
400
419
  }
401
420