@nuskin/cs-product-lib 1.0.28 → 1.0.29-9877-2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/csProduct.js +6 -5
- package/src/formatProduct.js +1 -0
- package/src/formatVariant.js +1 -0
- package/src/helpers.js +13 -1
package/package.json
CHANGED
package/src/csProduct.js
CHANGED
|
@@ -81,7 +81,7 @@ const csProduct = (props) => {
|
|
|
81
81
|
return props
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
const removeInvalidVariants = async (products, locale, translations) => {
|
|
84
|
+
const removeInvalidVariants = async (products = [], locale, translations) => {
|
|
85
85
|
const validSkus = []
|
|
86
86
|
for (const product of products) {
|
|
87
87
|
for (const variant of product?.variants || []) {
|
|
@@ -365,10 +365,11 @@ const csProduct = (props) => {
|
|
|
365
365
|
url += `&skip=${start}`
|
|
366
366
|
}
|
|
367
367
|
try {
|
|
368
|
-
const res = await axios(url)
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
368
|
+
const res = await axios(url);
|
|
369
|
+
if (onlyEntries) {
|
|
370
|
+
return res?.data?.entries ? res.data.entries : res
|
|
371
|
+
}
|
|
372
|
+
return res?.data?.entries ? res.data : res
|
|
372
373
|
} catch (error) {
|
|
373
374
|
return error
|
|
374
375
|
}
|
package/src/formatProduct.js
CHANGED
|
@@ -15,6 +15,7 @@ const formatProduct = (parent, homeUrl) => {
|
|
|
15
15
|
productImages: helpers?.getProductImages(parent),
|
|
16
16
|
salesLabel: parent?.sales_label,
|
|
17
17
|
salesText: parent?.sales_text,
|
|
18
|
+
activeEventDisclaimer: helpers?.mapActiveEventDisclaimer(parent?.active_event_disclaimer),
|
|
18
19
|
description: entities.decodeHTML(parent?.short_description || ''),
|
|
19
20
|
salesDisclaimer: helpers?.mapSalesDisclaimer(parent?.sales_disclaimer),
|
|
20
21
|
features: helpers?.mapFeatures(parent),
|
package/src/formatVariant.js
CHANGED
|
@@ -15,6 +15,7 @@ const formatVariant = (parent) => ({
|
|
|
15
15
|
title: parent?.name || parent?.defaults?.name,
|
|
16
16
|
salesLabel: parent?.sales_label,
|
|
17
17
|
salesText: parent?.sales_text,
|
|
18
|
+
activeEventDisclaimer: helpers?.mapActiveEventDisclaimer(parent?.active_event_disclaimer),
|
|
18
19
|
description: entities?.decodeHTML(
|
|
19
20
|
parent?.short_description_override || parent?.defaults?.description || ''
|
|
20
21
|
),
|
package/src/helpers.js
CHANGED
|
@@ -935,6 +935,17 @@ function mapDisclaimerWarnings(disclaimerWarnings) {
|
|
|
935
935
|
.filter((disclaimerWarning) => !!disclaimerWarning)
|
|
936
936
|
}
|
|
937
937
|
|
|
938
|
+
function mapActiveEventDisclaimer(activeEventDisclaimer) {
|
|
939
|
+
|
|
940
|
+
if (!hasRichTextContent(activeEventDisclaimer)) {
|
|
941
|
+
return null
|
|
942
|
+
}
|
|
943
|
+
const markdownText = createMarkdown(activeEventDisclaimer, '', '', '')
|
|
944
|
+
return {
|
|
945
|
+
markdownText
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
938
949
|
function hasRichTextContent(richText) {
|
|
939
950
|
// when cleared, the rich text json still contains children, this checks for any text or links
|
|
940
951
|
return ((richText || {}).children || []).some((line) =>
|
|
@@ -1168,5 +1179,6 @@ module.exports = {
|
|
|
1168
1179
|
reorderLocale,
|
|
1169
1180
|
mapFaqs,
|
|
1170
1181
|
createMarkdownFromRTE,
|
|
1171
|
-
benefitsToMarkdown
|
|
1182
|
+
benefitsToMarkdown,
|
|
1183
|
+
mapActiveEventDisclaimer
|
|
1172
1184
|
}
|