@nuskin/cs-product-lib 1.0.28 → 1.0.29-9877-2.1
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/formatProduct.js +1 -0
- package/src/formatVariant.js +1 -0
- package/src/helpers.js +13 -1
package/package.json
CHANGED
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
|
+
salesRichText: helpers?.mapSalesRichText(parent?.sales_rich_text),
|
|
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
|
+
salesRichText: helpers?.mapSalesRichText(parent?.sales_rich_text),
|
|
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 mapSalesRichText(salesRichText) {
|
|
939
|
+
|
|
940
|
+
if (!hasRichTextContent(salesRichText)) {
|
|
941
|
+
return null
|
|
942
|
+
}
|
|
943
|
+
const markdownText = createMarkdown(salesRichText, '', '', '')
|
|
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
|
+
mapSalesRichText
|
|
1172
1184
|
}
|