@nuskin/ns-product-lib 2.11.0-cx24-5092.24 → 2.11.0-cx24-5092.25

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.11.0-cx24-5092.25](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.24...v2.11.0-cx24-5092.25) (2023-09-18)
2
+
3
+
4
+ ### New
5
+
6
+ * Moving from AEM to CS for EQ markets ([5c95f51](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5c95f51f82eefe9dd5060a544f200facab0fbc38))
7
+
1
8
  # [2.11.0-cx24-5092.24](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.23...v2.11.0-cx24-5092.24) (2023-09-15)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.11.0-cx24-5092.24",
3
+ "version": "2.11.0-cx24-5092.25",
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": {
@@ -135,10 +135,10 @@ const ProductGraphQL = {
135
135
  "availableQuantity": response.variants[0].availableQuantity,
136
136
  "maxQuantity": response.variants[0].maxQuantity,
137
137
  "points": "",
138
- "cv": 0,
139
- "pv": 0,
138
+ "cv": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
139
+ "pv": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
140
140
  "priceType": "WRTL",
141
- "price": 0,
141
+ "price": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
142
142
  "priceMap": {
143
143
  "WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
144
144
  "WADW-WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retailSubscription : response.variants[0].price.retail,
@@ -149,14 +149,14 @@ const ProductGraphQL = {
149
149
  "WHL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesale : response.variants[0].price.wholesale
150
150
  },
151
151
  "cvMap": {
152
- "WWHL": response.variants[0].points.wholesale.cv,
153
- "WADW": response.variants[0].points.subscription.cv,
154
- "WHL": response.variants[0].points.wholesale.cv
152
+ "WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
153
+ "WADW": (response.variants[0].points) ? response.variants[0].points.subscription.cv : 0,
154
+ "WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0
155
155
  },
156
156
  "pvMap": {
157
- "WWHL": response.variants[0].points.wholesale.pv,
158
- "WADW": response.variants[0].points.subscription.pv,
159
- "WHL": response.variants[0].points.wholesale.pv
157
+ "WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
158
+ "WADW": (response.variants[0].points) ? response.variants[0].points.subscription.pv : 0,
159
+ "WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0
160
160
  },
161
161
  "orderTypes": this._setOrderType(response.variants[0].purchaseTypes),
162
162
  "custTypes": {},
@@ -168,7 +168,7 @@ const ProductGraphQL = {
168
168
  "variantDropdownLabel": response.variantSelectLabel || '',
169
169
  "variantDropdownPlaceholder": "Select Type",
170
170
  "variantsLabel": response.variants[0].variantLabel || '',
171
- "variants": [],
171
+ "variants": this.mapProductVariants(response.variants),
172
172
  "groupOffer": false,
173
173
  "personalOffer": false,
174
174
  "savedEventName": '',
@@ -184,6 +184,83 @@ const ProductGraphQL = {
184
184
  return res;
185
185
 
186
186
  },
187
+ mapProductVariants: function (response, globalProductID, market, locale) {
188
+ let variants = [];
189
+ variants.map((res, index) => {
190
+ if (index >= 1) {
191
+ return {
192
+ "sku": res.id,
193
+ "globalProductID": globalProductID,
194
+ "title": res.title,
195
+ "country": market,
196
+ "language": locale,
197
+ "shortDescr": res.description,
198
+ "longDescr": res.productDetails.description,
199
+ "fullImage": res.productImages[0].url,
200
+ "imageAltText": res.productImages[0].alt,
201
+
202
+ "thumbnail": res.productImages[0].thumbnail,
203
+ "ingredients": res.ingredients,
204
+ "benefits": res.benefits,
205
+ "usage": response.variants[0].usage,
206
+ "resources": res.resoruces,
207
+
208
+
209
+ "availableQuantity": res.availableQuantity,
210
+ "maxQuantity": res.maxQuantity,
211
+ "points": "",
212
+ "cv": (res.points) ? res.points.wholesale.cv : 0,
213
+ "pv": (res.points) ? res.points.wholesale.pv : 0,
214
+ "priceType": "WRTL",
215
+ "price": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
216
+ "priceMap": {
217
+ "WRTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
218
+ "WADW-WRTL": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retail,
219
+ "WADR": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retailSubscription, //retail ADR (subscription) price
220
+ "RTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
221
+ "WWHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale,
222
+ "WADW": (res.totalPrice) ? res.totalPrice.wholesaleSubscription : res.price.wholesaleSubscription,//wholesale ADR (subscription price)
223
+ "WHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale
224
+ },
225
+ "cvMap": {
226
+ "WWHL": (res.points) ? res.points.wholesale.cv : 0,
227
+ "WADW": (res.points) ? res.points.subscription.cv : 0,
228
+ "WHL": (res.points) ? res.points.wholesale.cv : 0
229
+ },
230
+ "pvMap": {
231
+ "WWHL": (res.points) ? res.points.wholesale.pv : 0,
232
+ "WADW": (res.points) ? res.points.subscription.pv : 0,
233
+ "WHL": (res.points) ? res.points.wholesale.pv : 0
234
+ },
235
+ "orderTypes": this._setOrderType(res.purchaseTypes),
236
+ "custTypes": {},
237
+ "backOrderDate": res.status.backorderedAvailableDate,
238
+
239
+ "size": res.size,
240
+ "status": this.switchStatusFromEquinox(res.status.status),
241
+ "variantType": "Other",
242
+ "variantDropdownLabel": response.variantSelectLabel || '',
243
+ "variantDropdownPlaceholder": "Select Type",
244
+ "variantsLabel": res.variantLabel || '',
245
+ "variants": [],
246
+ "groupOffer": false,
247
+ "personalOffer": false,
248
+ "savedEventName": '',
249
+ "salesLabel": '',
250
+ "eventName": '',
251
+ "sizeWeight": '',
252
+ "nettoWeight": "",
253
+ "searchScore": 0,
254
+ "isExclusive": res.isExclusive || false,
255
+ "equinoxProductId": response.id,
256
+ "properties": {}
257
+ }
258
+ }
259
+ })
260
+
261
+
262
+ return variants
263
+ },
187
264
  mapProductBundle: async function (response, market, locale) {
188
265
  let res;
189
266
  response.bundle.kitProducts.forEach((product) => {