@nuskin/ns-product-lib 2.5.0-cx24-2179.2.11 → 2.5.0-cx24-3175.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,116 +1,11 @@
1
- # [2.5.0-cx24-2179.2.11](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.10...v2.5.0-cx24-2179.2.11) (2023-01-16)
1
+ # [2.5.0-cx24-3175.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.5.0-cx24-3175.1) (2023-01-20)
2
2
 
3
3
 
4
- ### Fix
5
-
6
- * Equinox API called for non equinox market ([50eaa48](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/50eaa48a41a9e00d48ff79de35b955b817c4c0ea))
7
-
8
- # [2.5.0-cx24-2179.2.10](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.9...v2.5.0-cx24-2179.2.10) (2023-01-16)
9
-
10
-
11
- ### Fix
12
-
13
- * Equinox API called for non equinox market (CX24-3168) ([399e615](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/399e6150914dcafd5bd9fcd7ca0e0a95b65656d7))
14
-
15
- # [2.5.0-cx24-2179.2.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.8...v2.5.0-cx24-2179.2.9) (2022-12-20)
16
-
17
-
18
- ### Fix
19
-
20
- * eq market event pricing and name (#CX24-2179) ([213b59a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/213b59a33a208ffad0a6726521ce7f365d34d36e)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
21
- * Slow response of add-to-cart button function for Equinox Cart ([14394b2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/14394b299afbd53254a3ec053ad41e68ed526dfe))
22
- * Unit Tests ([ace52c6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ace52c6418991d0263a1e1f8d99901e724abf923))
23
-
24
- ### Release
25
-
26
- * Automated changes by GitLab pipeline [skip ci] ([eb755fa](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/eb755fae1e1f1f221a34d92f5ff4e64787a4132d))
27
- * Automated changes by GitLab pipeline [skip ci] ([6a75f7a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6a75f7a5f8b2f3b17e4d7387af37cad4f367b45c))
28
-
29
4
  ### Update
30
5
 
31
- * use configuration-sdk to pull the configurations (CX24-2931) ([6934570](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/69345701e6b44754ffeb648ead56f0288aadeb16))
32
-
33
- # [2.5.0-CX24.3.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-CX24.2.1...v2.5.0-CX24.3.1) (2022-12-06)
34
-
35
- * added eq promoion bypass for setPriceAndPvFromType v5 (#CX24-2179) ([f5b62e5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f5b62e5e82f1830d4105ffc965b64e9a7fc88d9b)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
36
-
37
- # [2.5.0-cx24-2179.2.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.5...v2.5.0-cx24-2179.2.6) (2022-12-05)
38
-
39
-
40
- ### New
41
-
42
- * added eq promoion bypass for setPriceAndPvFromType v4 (#CX24-2179) ([abcdd30](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/abcdd30223107786c0c2f9d1a8946053ef6dcef5)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
43
-
44
- # [2.5.0-cx24-2179.2.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.4...v2.5.0-cx24-2179.2.5) (2022-12-05)
45
-
46
-
47
- ### New
48
-
49
- * added eq promoion bypass for setPriceAndPvFromType v3 (#CX24-2179) ([79fe156](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/79fe1562d0cafc44f8945e57c316c8ba0b55a88b)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
50
-
51
- # [2.5.0-cx24-2179.2.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.3...v2.5.0-cx24-2179.2.4) (2022-12-05)
52
-
53
-
54
- ### New
55
-
56
- * added eq promoion bypass for setPriceAndPvFromType v2 (#CX24-2179) ([25bde9a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/25bde9a8e19b1e4e44e37457dfb087e0a6212ee1)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
57
-
58
- # [2.5.0-cx24-2179.2.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.2...v2.5.0-cx24-2179.2.3) (2022-12-05)
59
-
60
-
61
- ### New
62
-
63
- * added eq promoion bypass for setPriceAndPvFromType (#CX24-2179) ([716cefc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/716cefc2a2522287e017709a8b2cfef5a7ce5e07)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
64
-
65
- # [2.5.0-cx24-2179.2.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.1...v2.5.0-cx24-2179.2.2) (2022-12-05)
66
-
67
-
68
- ### New
69
-
70
- * added eq promotion support- debug sales event (#CX24-2179) ([992a2cf](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/992a2cfb178b3e12a6b8a0229ae5f6f607fb41d3)), closes [#CX24-2179](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2179)
71
-
72
- # [2.5.0-cx24-2179.2.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-CX24.2.1...v2.5.0-cx24-2179.2.1) (2022-12-02)
73
- >>>>>>> CX24.2
74
-
75
-
76
- ### Fix
77
-
78
- * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([a89af4a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a89af4a5d00c6a68fcaeff22f128554270add21e))
79
-
80
- ### Release
81
-
82
- * Automated changes by GitLab pipeline [skip ci] ([07bfa40](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/07bfa404c552c05637c2c8a537c4ff298536874e))
83
- * Automated changes by GitLab pipeline [skip ci] ([fa1c0d9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/fa1c0d9d5853482e3ac49cea4e99599e7192f85b))
84
- * Automated changes by GitLab pipeline [skip ci] ([2d20787](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2d2078763b2d57edb8a24f438ac90dd37c3ff41b))
85
-
86
- ### Update
87
-
88
- * set ADR pricing from equinox (CX24-2862) ([65d04d2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/65d04d2e9ff4018edfe99e5a7412bee985d3def2))
89
- * set ADR pricing from equinox (CX24-2862) ([54a5693](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/54a56932e5df36c9c30ce6358d8597c98be3d20d))
90
- * set ADR pricing from equinox (CX24-2862) ([bbd135f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bbd135f1ed0395c578be2274c84ba136ceed9376))
91
- * set ADR pricing from equinox (CX24-2862) ([197003e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/197003e1629bd394c547a118d332b5e8574dfc7d))
92
-
93
- # [2.5.0-cx24-2862.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2862.1...v2.5.0-cx24-2862.2) (2022-11-11)
94
-
95
-
96
- ### Update
97
-
98
- * set ADR pricing from equinox (CX24-2862) ([b64dcea](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b64dcea4dd3374be992c667db5c0b2604aacc029))
99
-
100
- # [2.5.0-cx24-2862.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.2-cx24-2612.1.1...v2.5.0-cx24-2862.1) (2022-11-10)
101
-
102
-
103
- ### Update
104
-
105
- * set ADR pricing from equinox (CX24-2862) ([9f6dfb7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f6dfb726f40b1335411318629a2ebdf1b4dac96))
106
- * set ADR pricing from equinox (CX24-2862) ([61f550a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/61f550a21c5cc9d062549ec2aaf2758aebccf2be))
107
-
108
- ## [2.4.2-cx24-2612.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.4.1...v2.4.2-cx24-2612.1.1) (2022-11-07)
109
-
110
-
111
- ### Fix
112
-
113
- * [Equinox market] Admin > Move up/down/top/bottom of featured products and edit bundle is not working ([9d9d106](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9d9d10667477b4c7ef7bf8ec013aab322d3cdbcc))
6
+ * remapped equinox isExclusive field (#CX24-3175) ([6adcee1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6adcee103ca720697152d253c135546af7393739)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
7
+ * remapped equinox properties after migration (#CX24-3175) ([cd1e3f6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cd1e3f6894b764283b026197412a6d1859b35a91)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
8
+ * remapped equinox variant label property (#CX24-3175) ([3c2a7dc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3c2a7dc4c9543577ae6a90f3f5df0f092707e2b6)), closes [#CX24-3175](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3175)
114
9
 
115
10
  ## [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)
116
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.5.0-cx24-2179.2.11",
3
+ "version": "2.5.0-cx24-3175.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": {
@@ -31,7 +31,6 @@
31
31
  "prettier": "1.19.1"
32
32
  },
33
33
  "dependencies": {
34
- "@nuskin/configuration-sdk": "1.0.1",
35
34
  "@nuskin/ns-common-lib": "1.4.5",
36
35
  "@nuskin/ns-util": "3.107.0",
37
36
  "axios": "0.27.2",
@@ -98,7 +98,7 @@ function getCachedData(key) {
98
98
  * @property {string} checkout_client_secret
99
99
  *
100
100
  * @export
101
- * @return {Promise<null|MarketConfig>}
101
+ * @return {Promise<null|MarketConfig>}
102
102
  */
103
103
  async function getAEMConfig() {
104
104
  try {
@@ -137,7 +137,7 @@ async function getAEMConfig() {
137
137
  * @property {string} market_name
138
138
  * @property {string} country_code
139
139
  * @property {string} store_id
140
- *
140
+ *
141
141
  * @typedef EquinoxEnabledMarkets
142
142
  * @property {EquinoxEnabledMarket[]} [dev_markets]
143
143
  * @property {EquinoxEnabledMarket[]} [test_markets]
@@ -145,7 +145,7 @@ async function getAEMConfig() {
145
145
  * @property {EquinoxEnabledMarket[]} [prod_markets]
146
146
  *
147
147
  * @export
148
- * @return {Promise<EquinoxEnabledMarkets>}
148
+ * @return {Promise<EquinoxEnabledMarkets>}
149
149
  */
150
150
  async function getEquinoxMarkets() {
151
151
  try {
@@ -176,8 +176,8 @@ async function getEquinoxMarkets() {
176
176
  }
177
177
  }
178
178
 
179
- /**getKongUrl gets the URL for Kong in contentstack
180
- *
179
+ /**getKongUrl gets the URL for Kong in contentstack
180
+ *
181
181
  * @returns {string}
182
182
  */
183
183
  async function getKongUrl() {
package/src/index.js CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  const Agelocme = require("./agelocme.js");
9
9
  const Contentstack = require('./contentstack/contentstack');
10
- const PriceType = require("./priceType.js");
10
+ const PriceType = require("./models/priceType.js");
11
11
  const Product = require("./product.js");
12
12
  const ProductContentMapper = require("./productContentMapper.js");
13
- const ProductStatus = require("./productStatus.js");
13
+ const ProductStatus = require("./models/productStatus.js");
14
14
  const ProductStatusMapper = require("./productStatusMapper.js");
15
15
  const ProductUtils = require("./productUtils.js");
16
16
  const ProductData = require("./productData.js");
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ const CustomerTypes = {
4
+ BrandAffiliate: "brandaffiliate",
5
+ Preferred: "preferred",
6
+ PreferredCustomer: "preferred customer",
7
+ Retail: "retail",
8
+ properties: {
9
+ BRAND_AFFILIATE: { stringKey: "DIST", code: 10 },
10
+ RETAIL: { stringKey: "CUST", code: 20 },
11
+ PREFERRED: { stringKey: "preferred", code: 30 },
12
+ PREFERRED_CUSTOMER: { stringKey: "PREF", code: 30 }
13
+ }
14
+ };
15
+
16
+ module.exports = CustomerTypes;
File without changes
@@ -17,6 +17,13 @@ const ProductStatus = {
17
17
  STOP_STATUS: { stringKey: "stopStatus", code: 5 },
18
18
  NOT_FOUND: { stringKey: "", code: 0 },
19
19
  NOT_SOLD_SEPERATELY: {stringKey: "notSoldSeperately", code: 4 }
20
+ },
21
+ equinoxStatus: {
22
+ SELLABLE: 'sellable',
23
+ PREVIEW_PRODUCT: 'preview product',
24
+ DISCONTINUED: 'discontinued',
25
+ STOPPED: 'stopped',
26
+ REPLACEMENT: 'Replacement'
20
27
  }
21
28
  };
22
29
 
package/src/product.js CHANGED
@@ -5,8 +5,8 @@ const { isTrue } = require("@nuskin/ns-common-lib");
5
5
  const ProductUtils = require("./productUtils.js");
6
6
 
7
7
  const Agelocme = require("./agelocme.js");
8
- const PriceType = require("./priceType.js");
9
- const ProductStatus = require("./productStatus.js");
8
+ const PriceType = require("./models/priceType.js");
9
+ const ProductStatus = require("./models/productStatus.js");
10
10
 
11
11
  const Product = function(productData) {
12
12
  this.priceMap = {};
@@ -75,7 +75,6 @@ const Product = function(productData) {
75
75
  //equinox inventory / stock label
76
76
  //@example "IN STOCK"
77
77
  this.inventory = "";
78
- this.equinoxProductId = "";
79
78
 
80
79
  this.setMarketAttributes = function(productStatus) {
81
80
  if (productStatus.marketAttributes) {
@@ -226,7 +225,7 @@ const Product = function(productData) {
226
225
  }
227
226
  };
228
227
 
229
- this.setPriceAndPvFromType = function(_priceType, _activeEvents = null, option = {}) {
228
+ this.setPriceAndPvFromType = function(_priceType, _activeEvents = null) {
230
229
  // WARNING: priceType needs to be handled client-side
231
230
  // const priceType = ConfigService.getMarketConfig().showWholeSalePricing && !AccountManager.isLoggedIn()
232
231
  // ? PriceType.WWHL
@@ -235,11 +234,11 @@ const Product = function(productData) {
235
234
  const eventPricing = getEventPricing(this, priceType, _activeEvents);
236
235
 
237
236
  let changed = false;
238
- if ((
237
+ if (
239
238
  !this.price ||
240
239
  priceType !== this.priceType ||
241
240
  this.eventName !== eventPricing.eventName
242
- ) && !option.isEqPromotion) {
241
+ ) {
243
242
  this.setPrice(eventPricing.price || this.getPricing(priceType));
244
243
  this.setCv(eventPricing.cv || this.getCvWithType(priceType));
245
244
  this.setPv(eventPricing.pv || this.getPvWithType(priceType));
@@ -248,20 +247,11 @@ const Product = function(productData) {
248
247
  changed = true;
249
248
  }
250
249
 
251
- if (option.isEqPromotion) {
252
- //retain product.price as original price
253
- this.setCv(this.getCvWithType(priceType));
254
- this.setPv(this.getPvWithType(priceType));
255
- this.priceType = priceType;
256
- changed = true;
257
- }
258
-
259
250
  this.variantSkus().forEach((variantSku) => {
260
251
  if (
261
252
  this.variants[variantSku].setPriceAndPvFromType(
262
253
  priceType,
263
- _activeEvents,
264
- option
254
+ _activeEvents
265
255
  )
266
256
  ) {
267
257
  changed = true;
@@ -291,7 +281,7 @@ const Product = function(productData) {
291
281
  this.priceMap[type] = price;
292
282
  };
293
283
 
294
- this.addPricingFromStatus = function(productStatus, priceType, option ={}) {
284
+ this.addPricingFromStatus = function(productStatus, priceType) {
295
285
  let modified = false;
296
286
 
297
287
  if (!priceType) {
@@ -329,13 +319,13 @@ const Product = function(productData) {
329
319
  if(productStatus.childSkus) {
330
320
  this.childSkus = productStatus.childSkus;
331
321
  }
332
- this.setPriceAndPvFromType(priceType, null, option);
322
+ this.setPriceAndPvFromType(priceType);
333
323
  modified = true;
334
324
  } else {
335
325
  let variant = this.getVariant(productStatusSku);
336
326
 
337
327
  if (variant) {
338
- if (variant.addPricingFromStatus(productStatus, priceType, option)) {
328
+ if (variant.addPricingFromStatus(productStatus, priceType)) {
339
329
  variant.setMarketAttributes(productStatus);
340
330
  updateBaseRanges(this, variant);
341
331
  modified = true;
@@ -533,7 +523,6 @@ const Product = function(productData) {
533
523
  retData.restrictedMarkets = this.restrictedMarkets;
534
524
  retData.addOns = this.addOns;
535
525
  retData.inventory = this.inventory;
536
- retData.equinoxProductId = this.equinoxProductId;
537
526
 
538
527
  return retData;
539
528
  };
@@ -673,8 +662,6 @@ const Product = function(productData) {
673
662
  if (data.agelocme) {
674
663
  this.agelocme = new Agelocme(data.agelocme);
675
664
  }
676
-
677
- this.equinoxProductId = data.equinoxProductId;
678
665
  }
679
666
  };
680
667
 
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
- const { getConfiguration } = require('@nuskin/configuration-sdk');
3
- // import { ConfigService } from '@nuskin/ns-util';
4
2
  const axios = require("axios");
5
3
  const contentstack = require('./contentstack/contentstack');
6
4
  const Product = require("./product");
7
-
5
+ const CustomerTypes = require('./models/customerTypes');
6
+ const ProductStatus = require("./models/productStatus");
8
7
  /** @type {*} */
9
8
  const ProductData = {
10
9
  /**
@@ -15,41 +14,37 @@ const ProductData = {
15
14
  */
16
15
  getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
17
16
  const localeMarket = `${locale}_${market}`;
18
-
17
+
19
18
  if (isEquinoxEnabled) {
20
- let config = (await getConfiguration({
21
- configMapNames: ['Equinox_Markets'],
22
- country: market,
23
- environment: 'test',
24
- clientId: '735b1eb810304bba966af0891ab54053'
25
- })).Equinox_Markets;
26
- if (config.country_code != '') {
27
- return await this.getProductFromEquinox(skus, localeMarket, config);
19
+ const marketConfig = await contentstack.isMarketEnabled(market);
20
+
21
+ if (marketConfig !== null) {
22
+ return await this.getProductFromEquinox(skus, localeMarket, marketConfig.store_id);
28
23
  }
29
24
  }
25
+
30
26
  return await this.getProductFromLegacy(skus, localeMarket);
31
27
  },
32
-
33
- getProductFromEquinox: async function (skus, locale, config) {
34
-
35
- const filter = `{"filters": [{"field": "index_key_skuId","operation": "IN", "value": "${skus.toString()}"}]}`;
28
+
29
+ getProductFromEquinox: async function (skus, locale, storeID) {
30
+ const filter = '{"filters":[{"field":"index_key_skuId","operation":"IN","value":"' + skus.toString() + '"}]}';
36
31
  axios.defaults.withCredentials = true;
37
32
 
38
- const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
33
+ const url = await contentstack.getKongUrl() + `/orchestrationservices/storefront/catalogs/search/`;
39
34
  const href = `${url}?filter=${encodeURI(filter)}`;
40
35
  const response = await axios.request({
41
36
  method: 'get',
42
37
  url: href,
43
38
  params: {
44
39
  locale,
45
- storeId: config.store_id
40
+ storeId: storeID
46
41
  },
47
42
  headers: this.getEquinoxRequestHeaders(),
48
43
  responseType: 'json'
49
44
  });
50
45
 
51
46
  if (response.data.product) {
52
- return this.eqProductMapper(response.data.product, skus);
47
+ return this.eqProductMapper(response.data.product);
53
48
  }
54
49
 
55
50
  return {
@@ -97,11 +92,11 @@ const ProductData = {
97
92
 
98
93
  /**
99
94
  * Map product variant
100
- * @todo remove unnecessary fields and do code refactoring
95
+ * @todo remove unnecessary fields
101
96
  * @param {*} eqVariant
102
97
  * @returns Array<Product>
103
98
  */
104
- eqProductVariantMapper : function (eqVariant) {
99
+ j : function (eqVariant) {
105
100
 
106
101
  let imageURL = eqVariant.properties.imageURL;
107
102
  const regex = /\d+.\d+/
@@ -113,10 +108,6 @@ const ProductData = {
113
108
  thumbnailImage = imageURL.replace(regex,'40.40')
114
109
  }
115
110
 
116
- const { eventName, eventLabels, computedPrice, defaultProductPrice} = this.getEqProductPromotions(eqVariant);
117
- const productPrice = eventName ? defaultProductPrice : eqVariant.priceFacets["Regular Price"];
118
- const discountedPrice = eventName ? computedPrice : eqVariant.priceFacets["Regular Price"];
119
-
120
111
  return {
121
112
  "sku": eqVariant.identifier,
122
113
  "globalProductID": eqVariant.identifier,
@@ -155,14 +146,14 @@ const ProductData = {
155
146
  "cv": (eqVariant.priceFacets.CV) ? eqVariant.priceFacets.CV : '',
156
147
  "pv":eqVariant.priceFacets.PV,
157
148
  "priceType": "WRTL",
158
- "price": discountedPrice,
149
+ "price": eqVariant.priceFacets["Regular Price"],
159
150
  "priceMap": {
160
- "WRTL": productPrice,
151
+ "WRTL": eqVariant.priceFacets["Regular Price"],
161
152
  "WADW-WRTL": eqVariant.priceFacets["Regular Price"],
162
- "WADR": eqVariant.priceFacets["Regular Price"],
153
+ "WADR": 9999.01,
163
154
  "RTL": eqVariant.priceFacets["Regular Price"],
164
155
  "WWHL": eqVariant.priceFacets["Wholesale Price"],
165
- "WADW": eqVariant.priceFacets["Wholesale Price"],
156
+ "WADW": 9998.01,
166
157
  "WHL": eqVariant.priceFacets["Wholesale Price"]
167
158
  },
168
159
  "cvMap": {
@@ -175,7 +166,19 @@ const ProductData = {
175
166
  "WADW": eqVariant.priceFacets.PV,
176
167
  "WHL": eqVariant.priceFacets.PV
177
168
  },
178
- "orderTypes": this._setOrderType(eqVariant.properties),
169
+ "orderTypes": {
170
+ "adr": true,
171
+ "order": true,
172
+ "zpfc": false,
173
+ "zadp": true,
174
+ "ars": true,
175
+ "kiosk": true,
176
+ "mobile": true,
177
+ "preferred customer": true,
178
+ "retail": true,
179
+ "web": true,
180
+ "web display": true
181
+ },
179
182
  "division": eqVariant.properties.division,
180
183
  "backOrderDate": null,
181
184
  "locallyProduced": false,
@@ -186,65 +189,29 @@ const ProductData = {
186
189
  "shade": "",
187
190
  "status": this.switchStatusFromEquinox(eqVariant.properties.status),
188
191
  "variantType": "Other",
189
- "variantDropdownLabel": eqVariant.properties.variantLabel || "",
192
+ "variantDropdownLabel": eqVariant.properties.variantSelectLabel || "",
190
193
  "variantDropdownPlaceholder": "Select Type",
191
- "variantsLabel": eqVariant.properties.variantLabel || "",
194
+ "variantsLabel": eqVariant.properties.variantSelectLabel || "",
192
195
  "groupOffer": false,
193
196
  "personalOffer": false,
194
- "savedEventName": eventName,
195
- "salesLabel": eventLabels,
196
- "eventName": eventName,
197
+ "savedEventName": null,
198
+ "salesLabel": "",
199
+ "eventName": null,
197
200
  "sizeWeight": '',
198
201
  "nettoWeight": "",
199
202
  "searchScore": 0,
200
- "isExclusive": false,
203
+ "isExclusive": eqVariant.properties.isExclusive || false,
201
204
  "marketAttributes": {
202
205
  "discount": true,
203
206
  "redeem": true,
204
207
  "earn": true
205
208
  },
206
209
  "restrictedMarkets": [],
207
- "addOns": [],
208
- "equinoxProductId": eqVariant.identifier
210
+ "addOns": []
209
211
  };
210
212
  },
211
213
 
212
- /**
213
- * Get EQ product promotions
214
- * @param {*} product
215
- * @returns {obj} promotion
216
- */
217
- getEqProductPromotions(product) {
218
-
219
- if (!Array.isArray(product.promotion)) {
220
- return {
221
- eventLabels: "",
222
- computedPrice : 0,
223
- defaultProductPrice: product.priceFacets ? product.priceFacets["Regular Price"] : 0,
224
- eventName: null
225
- }
226
- }
227
-
228
- const defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
229
- const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount ? product.totalValue.priceAfterDiscount : 0;
230
- let eventName = "";
231
- const eventLabels = [];
232
-
233
- product.promotion.map(promotion => {
234
- eventName = promotion.offerId;
235
- eventLabels.push(promotion.message);
236
- return promotion;
237
- });
238
-
239
- return {
240
- eventLabels: eventLabels.join(','),
241
- defaultProductPrice,
242
- computedPrice,
243
- eventName
244
- }
245
- },
246
-
247
- eqProductMapper: function (productDataResponse, skus) {
214
+ eqProductMapper: function (productDataResponse) {
248
215
  let prod = [];
249
216
  let count = 0;
250
217
  let variants = {};
@@ -261,17 +228,12 @@ const ProductData = {
261
228
  }
262
229
 
263
230
  if (data.sku && data.sku.length > 1) {
264
- //exclude base product from variants
265
- data.sku.filter(v => v.identifier.substring(2, 4) !== "55").map(variant => {
231
+ data.sku.map(variant => {
266
232
  variants[variant.identifier] = this.eqProductVariantMapper(variant);
267
233
  return variant;
268
234
  });
269
235
  }
270
236
 
271
- const { eventName, eventLabels, computedPrice, defaultProductPrice} = this.getEqProductPromotions(data.sku[count]);
272
- const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
273
- const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
274
-
275
237
  prod = {
276
238
  "sku": data.sku[count].identifier,
277
239
  "globalProductID": data.identifier,
@@ -310,13 +272,13 @@ const ProductData = {
310
272
  "cv": (data.sku[count].priceFacets.CV) ? data.sku[count].priceFacets.CV : '',
311
273
  "pv": data.sku[count].priceFacets.PV,
312
274
  "priceType": "WRTL",
313
- "price": discountedPrice,
275
+ "price": data.sku[count].priceFacets["Regular Price"],
314
276
  "priceMap": {
315
- "WRTL": productPrice,
277
+ "WRTL": data.sku[count].priceFacets["Regular Price"],
316
278
  "WADW-WRTL": data.sku[count].priceFacets["Regular Price"],
317
- "WADR": data.sku[count].priceFacets["Regular Price"],
279
+ "WADR": 9999.01,
318
280
  "RTL": data.sku[count].priceFacets["Regular Price"],
319
- "WADW": data.sku[count].priceFacets["Wholesale Price"],
281
+ "WADW": 9998.01,
320
282
  "WHL": data.sku[count].priceFacets["Wholesale Price"],
321
283
  "WWHL": data.sku[count].priceFacets["Wholesale Price"]
322
284
  },
@@ -330,7 +292,19 @@ const ProductData = {
330
292
  "WADW": data.sku[count].priceFacets.PV,
331
293
  "WHL": data.sku[count].priceFacets.PV
332
294
  },
333
- "orderTypes": this._setOrderType(data.sku[count].properties),
295
+ "orderTypes": {
296
+ "adr": true,
297
+ "order": true,
298
+ "zpfc": false,
299
+ "zadp": true,
300
+ "ars": true,
301
+ "kiosk": true,
302
+ "mobile": true,
303
+ "preferred customer": true,
304
+ "retail": true,
305
+ "web": true,
306
+ "web display": true
307
+ },
334
308
  "childSkus": [],
335
309
  "custTypes": this.switchCustType(data.properties.customerTypes),
336
310
  "division": data.properties.division,
@@ -348,14 +322,14 @@ const ProductData = {
348
322
  "variantsLabel": data.sku[count].properties.variantLabel || "",
349
323
  "groupOffer": false,
350
324
  "personalOffer": false,
351
- "savedEventName": eventName,
352
- "salesLabel": eventLabels,
353
- "eventName": eventName,
325
+ "savedEventName": null,
326
+ "salesLabel": "",
327
+ "eventName": null,
354
328
  "sizeWeight": '',
355
329
  "nettoWeight": "",
356
330
  "variants": variants,
357
331
  "searchScore": 0,
358
- "isExclusive": data.sku[count].properties.isExclusive,
332
+ "isExclusive": data.sku[count].properties.isExclusive || false,
359
333
  "marketAttributes": {
360
334
  "discount": true,
361
335
  "redeem": true,
@@ -363,15 +337,15 @@ const ProductData = {
363
337
  },
364
338
  "restrictedMarkets": [],
365
339
  "addOns": [],
366
- "inventory": data.sku[count].inventory || "", //inventory label
367
- "equinoxProductId": data.identifier
340
+ "inventory": data.sku[count].inventory || "" //inventory label
341
+
368
342
  };
369
343
  let newProduct = new Product(prod);
370
344
  return newProduct
371
- });
345
+ })
372
346
 
373
347
  let data = {
374
- products: this._sortProductsBySku(skus, prodArr),
348
+ products: prodArr,
375
349
  count: productDataResponse.length
376
350
  };
377
351
  return {
@@ -384,27 +358,29 @@ const ProductData = {
384
358
  },
385
359
 
386
360
  switchStatusFromEquinox: function (status) {
361
+ const { equinoxStatus } = ProductStatus;
387
362
  let newStatus = '';
388
- switch (status) {
389
- case 'Sellable':
390
- newStatus = 'RELEASED_FOR_SALE';
363
+ switch (status.toLowerCase()) {
364
+ case equinoxStatus.SELLABLE:
365
+ newStatus = ProductStatus.ReleasedForSale;
391
366
  break;
392
- case 'Preview product':
393
- newStatus = 'NOT_RELEASED_FOR_SALE';
367
+ case equinoxStatus.PREVIEW_PRODUCT:
368
+ newStatus = ProductStatus.NotReleasedForSale;
394
369
  break;
395
- case 'Discontinued':
396
- newStatus = 'DISCONTINUED';
370
+ case equinoxStatus.DISCONTINUED:
371
+ newStatus = ProductStatus.Discontinued;
397
372
  break;
398
- case 'Stopped':
399
- newStatus = 'DISCONTINUED';
373
+ case equinoxStatus.STOPPED:
374
+ newStatus = ProductStatus.Discontinued;
400
375
  break;
401
- case 'Replacement':
402
- newStatus = 'NOT_RELEASED_FOR_SALE';
376
+ case equinoxStatus.REPLACEMENT:
377
+ newStatus = ProductStatus.NotReleasedForSale;
403
378
  break;
404
379
  default:
405
- newStatus = 'NOT_RELEASED_FOR_SALE'
380
+ newStatus = ProductStatus.NotReleasedForSale;
406
381
  break;
407
382
  }
383
+
408
384
  return newStatus;
409
385
  },
410
386
 
@@ -413,92 +389,33 @@ const ProductData = {
413
389
  * @param {*} custType
414
390
  *
415
391
  */
416
- switchCustType: function (custType) {
417
- let newCustType = [];
418
- if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
419
- newCustType.push(10)
420
- if (custType.includes('Retail Customer'))
421
- newCustType.push(20)
422
- if (custType.includes('Preferred Customer/Member'))
423
- newCustType.push(30)
424
- return newCustType.toString()
425
- },
426
392
 
427
393
  /**
428
- * Sorts the product by sku
429
- * @param {Array} skus - the skus arrangment which the sorting will base out of
430
- * @param {Array} products - this products to be sorted
394
+ * map customer types from string to code
395
+ * @param {*} eqCustomerTypes
396
+ * @returns
431
397
  */
432
-
433
- _sortProductsBySku: function (skus, products) {
434
-
435
- if(!skus || !products || products.length === 1) {
436
- return products
398
+ switchCustType: function (eqCustomerTypes) {
399
+ if (!eqCustomerTypes) {
400
+ return "";
437
401
  }
438
402
 
439
- const sortedProducts = products.sort(function (a, b) {
440
- return skus.indexOf(a.sku) - skus.indexOf(b.sku);
441
- });
442
-
443
- return sortedProducts
403
+ const custTypes = eqCustomerTypes.split(',').map(customerType => customerType.toLowerCase());
444
404
 
445
- },
405
+ let newCustType = [];
406
+ if (custTypes.includes(CustomerTypes.BrandAffiliate)) {
407
+ newCustType.push(CustomerTypes.properties.BRAND_AFFILIATE.code);
408
+ }
446
409
 
447
- /**
448
- *
449
- * @param {*} availableChannels
450
- *
451
- * This function is use to convert arsPhone,web,kiosk,mobile,subscription
452
- * to orderType object
453
- * "adr”
454
- "order"
455
- "zpfc"
456
- "zadp"
457
- "ars"
458
- "kiosk"
459
- "mobile"
460
- "preferred customer"
461
- "retail"
462
- "web"
463
- "web display"
464
- */
465
- _setOrderType: function (properties) {
466
- let orderTypeArr = {
467
- "adr": false,
468
- "order": false,
469
- "zpfc": false,
470
- "zadp": false,
471
- "ars": false,
472
- "kiosk": false,
473
- "mobile": false,
474
- "preferred customer": false,
475
- "retail": false,
476
- "web": false,
477
- "web display": false
478
- };
479
- let availableChannelsArr = properties.availableChannels.split(',')
480
-
481
- availableChannelsArr.forEach(channel => {
482
- if (channel == 'arsPhone')
483
- orderTypeArr.ars = true
484
- if (channel == 'web') {
485
- orderTypeArr.order = true
486
- orderTypeArr.web = true
487
- }
488
- if (channel == 'kiosk')
489
- orderTypeArr.kiosk = true
490
- if (channel == 'mobile')
491
- orderTypeArr.mobile = true
492
- if (channel == 'subscription')
493
- orderTypeArr.adr = true
410
+ if (custTypes.includes(CustomerTypes.Retail)) {
411
+ newCustType.push(CustomerTypes.properties.RETAIL.code);
412
+ }
494
413
 
495
- });
496
- if (properties.retail)
497
- orderTypeArr.retail = true
498
- if (properties.prefferredCustomer)
499
- orderTypeArr['preferred customer'] = true
414
+ if (custTypes.includes(CustomerTypes.Preferred) || custTypes.includes(CustomerTypes.PreferredCustomer)) {
415
+ newCustType.push(CustomerTypes.properties.PREFERRED.code);
416
+ }
500
417
 
501
- return orderTypeArr;
418
+ return newCustType.toString()
502
419
  }
503
420
  }
504
421