@nuskin/ns-product-lib 2.11.0-cx24-5092.24 → 2.11.0-cx24-5092.26
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/productGraphQL.js +94 -16
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [2.11.0-cx24-5092.26](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.25...v2.11.0-cx24-5092.26) (2023-09-18)
|
2
|
+
|
3
|
+
|
4
|
+
### New
|
5
|
+
|
6
|
+
* Moving from AEM to CS for EQ markets ([cb2a5b3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/cb2a5b3087fb6ee00e5bcd0b95ae67c16eaf7b1d))
|
7
|
+
|
8
|
+
# [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)
|
9
|
+
|
10
|
+
|
11
|
+
### New
|
12
|
+
|
13
|
+
* Moving from AEM to CS for EQ markets ([5c95f51](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5c95f51f82eefe9dd5060a544f200facab0fbc38))
|
14
|
+
|
1
15
|
# [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
16
|
|
3
17
|
|
package/package.json
CHANGED
package/src/productGraphQL.js
CHANGED
@@ -11,6 +11,7 @@ const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
|
|
11
11
|
|
12
12
|
|
13
13
|
|
14
|
+
|
14
15
|
const ProductGraphQL = {
|
15
16
|
getProductGraphqlUrl: function () {
|
16
17
|
const env = getEnvironmentFromUrl(window.location.host);
|
@@ -99,16 +100,18 @@ const ProductGraphQL = {
|
|
99
100
|
},
|
100
101
|
|
101
102
|
mapResponseToProduct: async function (response, market, locale, config) {
|
102
|
-
console.log('RESPONSE ' + JSON.stringify(response))
|
103
|
+
//console.log('RESPONSE ' + JSON.stringify(response))
|
103
104
|
let res;
|
104
105
|
if (response.variants.length >= 1) {
|
105
106
|
res = await this.mapProductRegular(response, market, locale, config)
|
106
107
|
}
|
107
108
|
if (response.bundles) {
|
108
|
-
|
109
|
+
res = await this.mapProductBundle(response, market.locale, config)
|
109
110
|
}
|
110
111
|
|
111
|
-
const
|
112
|
+
const productID = (response.id) ? response.id : response.variants[0].id
|
113
|
+
|
114
|
+
const promotions = await this.getProductPromotions(response.variants[0].sku, productID, config, locale)
|
112
115
|
console.log(promotions)
|
113
116
|
return res;
|
114
117
|
},
|
@@ -135,10 +138,10 @@ const ProductGraphQL = {
|
|
135
138
|
"availableQuantity": response.variants[0].availableQuantity,
|
136
139
|
"maxQuantity": response.variants[0].maxQuantity,
|
137
140
|
"points": "",
|
138
|
-
"cv": 0,
|
139
|
-
"pv": 0,
|
141
|
+
"cv": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
|
142
|
+
"pv": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
|
140
143
|
"priceType": "WRTL",
|
141
|
-
"price": 0,
|
144
|
+
"price": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
142
145
|
"priceMap": {
|
143
146
|
"WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retail : response.variants[0].price.retail,
|
144
147
|
"WADW-WRTL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.retailSubscription : response.variants[0].price.retail,
|
@@ -149,14 +152,14 @@ const ProductGraphQL = {
|
|
149
152
|
"WHL": (response.variants[0].totalPrice) ? response.variants[0].totalPrice.wholesale : response.variants[0].price.wholesale
|
150
153
|
},
|
151
154
|
"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
|
155
|
+
"WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0,
|
156
|
+
"WADW": (response.variants[0].points) ? response.variants[0].points.subscription.cv : 0,
|
157
|
+
"WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.cv : 0
|
155
158
|
},
|
156
159
|
"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
|
160
|
+
"WWHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0,
|
161
|
+
"WADW": (response.variants[0].points) ? response.variants[0].points.subscription.pv : 0,
|
162
|
+
"WHL": (response.variants[0].points) ? response.variants[0].points.wholesale.pv : 0
|
160
163
|
},
|
161
164
|
"orderTypes": this._setOrderType(response.variants[0].purchaseTypes),
|
162
165
|
"custTypes": {},
|
@@ -168,7 +171,7 @@ const ProductGraphQL = {
|
|
168
171
|
"variantDropdownLabel": response.variantSelectLabel || '',
|
169
172
|
"variantDropdownPlaceholder": "Select Type",
|
170
173
|
"variantsLabel": response.variants[0].variantLabel || '',
|
171
|
-
"variants":
|
174
|
+
"variants": this.mapProductVariants(response.variants),
|
172
175
|
"groupOffer": false,
|
173
176
|
"personalOffer": false,
|
174
177
|
"savedEventName": '',
|
@@ -184,11 +187,86 @@ const ProductGraphQL = {
|
|
184
187
|
return res;
|
185
188
|
|
186
189
|
},
|
190
|
+
mapProductVariants: function (response, globalProductID, market, locale) {
|
191
|
+
let variants = [];
|
192
|
+
variants.map((res, index) => {
|
193
|
+
if (index >= 1) {
|
194
|
+
return {
|
195
|
+
"sku": res.id,
|
196
|
+
"globalProductID": globalProductID,
|
197
|
+
"title": res.title,
|
198
|
+
"country": market,
|
199
|
+
"language": locale,
|
200
|
+
"shortDescr": res.description,
|
201
|
+
"longDescr": res.productDetails.description,
|
202
|
+
"fullImage": res.productImages[0].url,
|
203
|
+
"imageAltText": res.productImages[0].alt,
|
204
|
+
|
205
|
+
"thumbnail": res.productImages[0].thumbnail,
|
206
|
+
"ingredients": res.ingredients,
|
207
|
+
"benefits": res.benefits,
|
208
|
+
"usage": response.variants[0].usage,
|
209
|
+
"resources": res.resoruces,
|
210
|
+
|
211
|
+
|
212
|
+
"availableQuantity": res.availableQuantity,
|
213
|
+
"maxQuantity": res.maxQuantity,
|
214
|
+
"points": "",
|
215
|
+
"cv": (res.points) ? res.points.wholesale.cv : 0,
|
216
|
+
"pv": (res.points) ? res.points.wholesale.pv : 0,
|
217
|
+
"priceType": "WRTL",
|
218
|
+
"price": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
219
|
+
"priceMap": {
|
220
|
+
"WRTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
221
|
+
"WADW-WRTL": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retail,
|
222
|
+
"WADR": (res.totalPrice) ? res.totalPrice.retailSubscription : res.price.retailSubscription, //retail ADR (subscription) price
|
223
|
+
"RTL": (res.totalPrice) ? res.totalPrice.retail : res.price.retail,
|
224
|
+
"WWHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale,
|
225
|
+
"WADW": (res.totalPrice) ? res.totalPrice.wholesaleSubscription : res.price.wholesaleSubscription,//wholesale ADR (subscription price)
|
226
|
+
"WHL": (res.totalPrice) ? res.totalPrice.wholesale : res.price.wholesale
|
227
|
+
},
|
228
|
+
"cvMap": {
|
229
|
+
"WWHL": (res.points) ? res.points.wholesale.cv : 0,
|
230
|
+
"WADW": (res.points) ? res.points.subscription.cv : 0,
|
231
|
+
"WHL": (res.points) ? res.points.wholesale.cv : 0
|
232
|
+
},
|
233
|
+
"pvMap": {
|
234
|
+
"WWHL": (res.points) ? res.points.wholesale.pv : 0,
|
235
|
+
"WADW": (res.points) ? res.points.subscription.pv : 0,
|
236
|
+
"WHL": (res.points) ? res.points.wholesale.pv : 0
|
237
|
+
},
|
238
|
+
"orderTypes": this._setOrderType(res.purchaseTypes),
|
239
|
+
"custTypes": {},
|
240
|
+
"backOrderDate": res.status.backorderedAvailableDate,
|
241
|
+
|
242
|
+
"size": res.size,
|
243
|
+
"status": this.switchStatusFromEquinox(res.status.status),
|
244
|
+
"variantType": "Other",
|
245
|
+
"variantDropdownLabel": response.variantSelectLabel || '',
|
246
|
+
"variantDropdownPlaceholder": "Select Type",
|
247
|
+
"variantsLabel": res.variantLabel || '',
|
248
|
+
"variants": [],
|
249
|
+
"groupOffer": false,
|
250
|
+
"personalOffer": false,
|
251
|
+
"savedEventName": '',
|
252
|
+
"salesLabel": '',
|
253
|
+
"eventName": '',
|
254
|
+
"sizeWeight": '',
|
255
|
+
"nettoWeight": "",
|
256
|
+
"searchScore": 0,
|
257
|
+
"isExclusive": res.isExclusive || false,
|
258
|
+
"equinoxProductId": response.id,
|
259
|
+
"properties": {}
|
260
|
+
}
|
261
|
+
}
|
262
|
+
})
|
263
|
+
|
264
|
+
|
265
|
+
return variants
|
266
|
+
},
|
187
267
|
mapProductBundle: async function (response, market, locale) {
|
188
268
|
let res;
|
189
|
-
response.
|
190
|
-
res = this.mapProductRegular(product, market, locale)
|
191
|
-
})
|
269
|
+
res = this.mapProductRegular(response.bundles.kitProducts[0].product, market, locale)
|
192
270
|
return res;
|
193
271
|
},
|
194
272
|
/**
|