@nuskin/ns-product-lib 2.5.0-cx24-2179.2.17 → 2.5.0-cx24-2556.10.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/contentstack/contentstack.js +2 -99
- package/src/productData.js +91 -6
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# [2.5.0-cx24-2556.10.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.17...v2.5.0-cx24-2556.10.1) (2023-01-26)
|
2
|
+
|
3
|
+
|
4
|
+
### Update
|
5
|
+
|
6
|
+
* dynamically select environment (CX24-2556) ([3ba9fea](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3ba9fea8a3e308b25f8dea39572af59f86b4d2b8))
|
7
|
+
* dynamically select environment (CX24-2556) ([4729d82](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4729d82e49c9a21d17f3e6a619b25fe0aa51dc88))
|
8
|
+
|
1
9
|
# [2.5.0-cx24-2179.2.17](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.5.0-cx24-2179.2.16...v2.5.0-cx24-2179.2.17) (2023-01-24)
|
2
10
|
|
3
11
|
|
package/package.json
CHANGED
@@ -130,100 +130,6 @@ async function getAEMConfig() {
|
|
130
130
|
}
|
131
131
|
}
|
132
132
|
|
133
|
-
/**
|
134
|
-
* getEquinoxMarkets will get the list of Equinox-enabled markets from contentstack
|
135
|
-
*
|
136
|
-
* @typedef EquinoxEnabledMarket
|
137
|
-
* @property {string} market_name
|
138
|
-
* @property {string} country_code
|
139
|
-
* @property {string} store_id
|
140
|
-
*
|
141
|
-
* @typedef EquinoxEnabledMarkets
|
142
|
-
* @property {EquinoxEnabledMarket[]} [dev_markets]
|
143
|
-
* @property {EquinoxEnabledMarket[]} [test_markets]
|
144
|
-
* @property {EquinoxEnabledMarket[]} [staging_markets]
|
145
|
-
* @property {EquinoxEnabledMarket[]} [prod_markets]
|
146
|
-
*
|
147
|
-
* @export
|
148
|
-
* @return {Promise<EquinoxEnabledMarkets>}
|
149
|
-
*/
|
150
|
-
async function getEquinoxMarkets() {
|
151
|
-
try {
|
152
|
-
if (isCacheExpired(cacheKeys.equinoxMarkets)) {
|
153
|
-
const marketConfig = `${platform.env}_markets`;
|
154
|
-
const variables = { uid: 'blt5633ff9e560f14ef' };
|
155
|
-
const query = `query EquinoxMarketsByUid($uid: String!) {
|
156
|
-
equinox_markets(uid: $uid) {
|
157
|
-
${marketConfig} {
|
158
|
-
market_name
|
159
|
-
country_code
|
160
|
-
store_id
|
161
|
-
}
|
162
|
-
}
|
163
|
-
}`;
|
164
|
-
|
165
|
-
const { data } = await contentstackService({
|
166
|
-
data: { variables, query }
|
167
|
-
});
|
168
|
-
|
169
|
-
setCachedData(cacheKeys.equinoxMarkets, data.equinox_markets[marketConfig]);
|
170
|
-
}
|
171
|
-
|
172
|
-
return getCachedData(cacheKeys.equinoxMarkets);
|
173
|
-
} catch (error) {
|
174
|
-
console.error(error);
|
175
|
-
return [];
|
176
|
-
}
|
177
|
-
}
|
178
|
-
|
179
|
-
/**getKongUrl gets the URL for Kong in contentstack
|
180
|
-
*
|
181
|
-
* @returns {string}
|
182
|
-
*/
|
183
|
-
async function getKongUrl() {
|
184
|
-
try {
|
185
|
-
if (isCacheExpired(cacheKeys.kongUrl)) {
|
186
|
-
const variables = { uid: 'blt5633ff9e560f14ef' };
|
187
|
-
const query = `query KongUrlByUid($uid: String!) {
|
188
|
-
equinox_markets(uid: $uid) {
|
189
|
-
kong_urls {
|
190
|
-
${platform.env}
|
191
|
-
}
|
192
|
-
}
|
193
|
-
}`;
|
194
|
-
|
195
|
-
const { data } = await contentstackService({
|
196
|
-
data: { variables, query }
|
197
|
-
});
|
198
|
-
|
199
|
-
setCachedData(cacheKeys.kongUrl, data.equinox_markets.kong_urls[platform.env]);
|
200
|
-
}
|
201
|
-
|
202
|
-
return getCachedData(cacheKeys.kongUrl);
|
203
|
-
} catch (error) {
|
204
|
-
console.error(error);
|
205
|
-
return [];
|
206
|
-
}
|
207
|
-
}
|
208
|
-
|
209
|
-
/**
|
210
|
-
* isMarketEnabled checks is the given market is in the list
|
211
|
-
* of equinox-enabled markets.
|
212
|
-
*
|
213
|
-
* @param {string} market
|
214
|
-
* @returns {EquinoxEnabledMarket|null}
|
215
|
-
*/
|
216
|
-
async function isMarketEnabled(market) {
|
217
|
-
const markets = await getEquinoxMarkets();
|
218
|
-
const currentMarket = markets.filter(m => m.country_code.toLowerCase() === market.toLowerCase());
|
219
|
-
|
220
|
-
if (currentMarket.length > 0) {
|
221
|
-
return currentMarket[0];
|
222
|
-
}
|
223
|
-
|
224
|
-
return null;
|
225
|
-
}
|
226
|
-
|
227
133
|
/**
|
228
134
|
* Contentstack HTTP - axios wrapper for contentstack request
|
229
135
|
*
|
@@ -243,8 +149,5 @@ async function contentstackService(config) {
|
|
243
149
|
}
|
244
150
|
|
245
151
|
module.exports = {
|
246
|
-
getAEMConfig
|
247
|
-
|
248
|
-
isMarketEnabled,
|
249
|
-
getKongUrl
|
250
|
-
}
|
152
|
+
getAEMConfig
|
153
|
+
}
|
package/src/productData.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
const { getConfiguration } = require('@nuskin/configuration-sdk');
|
3
|
-
|
3
|
+
const { getEnvironmentFromUrl } = require('@nuskin/ns-common-lib');
|
4
4
|
const axios = require("axios");
|
5
5
|
const contentstack = require('./contentstack/contentstack');
|
6
6
|
const Product = require("./product");
|
@@ -8,7 +8,7 @@ const CustomerTypes = require('./models/customerTypes');
|
|
8
8
|
const ProductStatus = require("./models/productStatus");
|
9
9
|
/** @type {*} */
|
10
10
|
const ProductData = {
|
11
|
-
/**
|
11
|
+
/**
|
12
12
|
* @param {string[]} skus
|
13
13
|
* @param {string} locale
|
14
14
|
* @param {string} market
|
@@ -21,7 +21,7 @@ const ProductData = {
|
|
21
21
|
let config = (await getConfiguration({
|
22
22
|
configMapNames: ['Equinox_Markets'],
|
23
23
|
country: market,
|
24
|
-
environment:
|
24
|
+
environment: contentstackEnv(),
|
25
25
|
clientId: '735b1eb810304bba966af0891ab54053'
|
26
26
|
}));
|
27
27
|
|
@@ -146,7 +146,77 @@ const ProductData = {
|
|
146
146
|
"salesEventText": "",
|
147
147
|
"contentSection": [
|
148
148
|
{
|
149
|
-
"sectionContent":
|
149
|
+
"sectionContent": `<div class="contentSections">
|
150
|
+
<div class="contentSection section">
|
151
|
+
<div>\n<h3>BENEFITS</h3>\n
|
152
|
+
<div>\n
|
153
|
+
<div class="sectionContent parsys">
|
154
|
+
<div class="text parbase section">\n
|
155
|
+
<p>
|
156
|
+
Green tea has been used in China for thousands of years for its health-preserving and
|
157
|
+
revitalizing power. Modern science has identified powerful antioxidants in green tea
|
158
|
+
called polyphenols. One group of polyphenols called catechins is particularly potent
|
159
|
+
and is highly effective at neutralizing free radicals at the cellular level. Catechins
|
160
|
+
support healthy cell function while providing antioxidant protection to critical cell
|
161
|
+
structures such as DNA. Clinical studies show catechins interfere with the production
|
162
|
+
of certain enzymes involved in cell damage. Additionally, catechins have been demonstrated
|
163
|
+
to cause a thermogenic effect that enhances the body s metabolic rate. Tegreen 97<sup>®</sup>
|
164
|
+
from Pharmanex is a proprietary, highly concentrated extract of the catechins found
|
165
|
+
in green tea. Tegreen 97<sup>®</sup> is one of the most potent antioxidant supplements
|
166
|
+
on the market with a 97 percent polyphenol content, 65% catechins. Each Tegreen 97<sup>®</sup>
|
167
|
+
capsule contains the catechin equivalent of approximately seven cups of green tea and is
|
168
|
+
99.5 percent caffeine free.
|
169
|
+
</p>\r\n\n
|
170
|
+
</div>\n\n
|
171
|
+
</div>\n\n
|
172
|
+
</div>\n
|
173
|
+
</div>\n
|
174
|
+
</div>\n
|
175
|
+
<div class="contentSection section">
|
176
|
+
<div>\n<h3>USAGE</h3>\n
|
177
|
+
<div>\n
|
178
|
+
<div class="sectionContent parsys">
|
179
|
+
<div class="text parbase section">\n
|
180
|
+
<p>As a dietary supplement, take one (1) to four (4) capsules daily; preferably one (1)
|
181
|
+
to two (2) each morning and evening with food. Store in a cool, dry place.</p>\r\n\n
|
182
|
+
</div>\n\n
|
183
|
+
</div>\n\n
|
184
|
+
</div>\n
|
185
|
+
</div>\n
|
186
|
+
</div>\n
|
187
|
+
<div class="contentSection section">
|
188
|
+
<div>\n<h3>INGREDIENTS</h3>\n
|
189
|
+
<div>\n
|
190
|
+
<div class="sectionContent parsys">
|
191
|
+
<div class="text parbase section">\n
|
192
|
+
<table border="1" cellspacing="1" cellpadding="0" width="360">
|
193
|
+
<tbody>\r\n
|
194
|
+
<tr>\r\n
|
195
|
+
<td><b>Nutritional Facts</b></td>\r\n
|
196
|
+
<td><b>Amount</b></td>\r\n<td><b>% Daily Value</b></td>\r\n
|
197
|
+
</tr>\r\n
|
198
|
+
<tr>\r\n
|
199
|
+
<td colspan="3"><b>Serving Size: 1 Capsule<br>\r\nServings Per Container: 120</b></td>\r\n
|
200
|
+
</tr>\r\n
|
201
|
+
<tr>\r\n
|
202
|
+
<td width="55%">Green tea leaf (20:1) Extract (<i>Camellia sinensis</i></td>\r\n
|
203
|
+
<td width="20%">250 mg</td>\r\n<td width="25%"> </td>\r\n
|
204
|
+
</tr>\r\n
|
205
|
+
<tr>\r\n<td width="55%" colspan="3">* Daily Value not established</td>\r\n</tr>\r\n
|
206
|
+
<tr>\r\n
|
207
|
+
<td width="55%" colspan="3">
|
208
|
+
<b>Other Ingredients: Gelatin, Silicon Dioxide,
|
209
|
+
Microcrystalline Cellulose, Magnesium Stearate.</b>
|
210
|
+
</td>\r\n</tr>\r\n
|
211
|
+
</tbody>\r\n
|
212
|
+
</table>\r\n
|
213
|
+
<p> </p>\r\n\n
|
214
|
+
</div>\n\n
|
215
|
+
</div>\n\n
|
216
|
+
</div>\n
|
217
|
+
</div>\n
|
218
|
+
</div>\n
|
219
|
+
</div>\n`
|
150
220
|
}
|
151
221
|
],
|
152
222
|
"scanQualified": eqVariant.properties.scanQualifiedCount,
|
@@ -228,7 +298,9 @@ const ProductData = {
|
|
228
298
|
}
|
229
299
|
|
230
300
|
const defaultProductPrice = product.totalValue ? product.totalValue.originalPrice : 0;
|
231
|
-
const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
|
301
|
+
const computedPrice = product.totalValue && product.totalValue.priceAfterDiscount
|
302
|
+
? product.totalValue.priceAfterDiscount
|
303
|
+
: 0;
|
232
304
|
let eventName = "";
|
233
305
|
const eventLabels = [];
|
234
306
|
|
@@ -270,7 +342,12 @@ const ProductData = {
|
|
270
342
|
});
|
271
343
|
}
|
272
344
|
|
273
|
-
const {
|
345
|
+
const {
|
346
|
+
eventName,
|
347
|
+
eventLabels,
|
348
|
+
computedPrice,
|
349
|
+
defaultProductPrice
|
350
|
+
} = this.getEqProductPromotions(data.sku[count]);
|
274
351
|
const productPrice = eventName ? defaultProductPrice : data.sku[count].priceFacets["Regular Price"];
|
275
352
|
const discountedPrice = eventName ? computedPrice : data.sku[count].priceFacets["Regular Price"];
|
276
353
|
|
@@ -524,4 +601,12 @@ const ProductData = {
|
|
524
601
|
}
|
525
602
|
}
|
526
603
|
|
604
|
+
function contentstackEnv() {
|
605
|
+
if (typeof window === 'undefined') {
|
606
|
+
return 'test';
|
607
|
+
}
|
608
|
+
|
609
|
+
return getEnvironmentFromUrl(window.location.host);
|
610
|
+
}
|
611
|
+
|
527
612
|
module.exports = ProductData;
|