@nuskin/cs-product-lib 1.5.0-td-3879.5 → 1.5.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/cs-product-lib",
3
- "version": "1.5.0-td-3879.5",
3
+ "version": "1.5.0",
4
4
  "description": "Library for pulling and parsing product content (and applying business logic) retrieved from Contentstack",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/csProduct.js CHANGED
@@ -669,7 +669,7 @@ const csProduct = (props) => {
669
669
  locale
670
670
  });
671
671
  return badges.map(badge => {
672
- return helpers.parsePrysmBadge(badge, {})
672
+ return helpers.parsePrysmBadge(badge)
673
673
  })
674
674
 
675
675
  } catch (error) {
@@ -120,7 +120,7 @@ const formatVariant = (parent) => {
120
120
  foreignOrderLimit: helpers?.getBestSkuData(parent)?.foreign_limit,
121
121
  orderType: parent.sap_data?.order_type,
122
122
  discontinuedSkuReplacement: helpers?.mapDiscontinuedSkuReplacement(parent)?.sku,
123
- prysmData: helpers?.mapPrysmBadge(parent)
123
+ prysmData: helpers?.mapPrysmData(parent)
124
124
  }
125
125
  }
126
126
 
package/src/helpers.js CHANGED
@@ -1179,21 +1179,31 @@ function mapDiscontinuedSkuReplacement (product) {
1179
1179
  }
1180
1180
  }
1181
1181
 
1182
- function mapPrysmBadge(product){
1182
+ function mapPrysmData(product){
1183
1183
  const prysmBadgeGroup = product?.prysm;
1184
1184
  const prysmBadge = prysmBadgeGroup?.badge?.[0];
1185
- return parsePrysmBadge(prysmBadge, prysmBadgeGroup);
1185
+ const parsedPrysmBadge = parsePrysmBadge(prysmBadge);
1186
+ const prysmFunction = prysmBadgeGroup?.function;
1187
+ if(isNullOrEmpty(prysmFunction) && isNullOrEmpty(parsedPrysmBadge)){
1188
+ return null;
1189
+ }
1190
+ return {
1191
+ function: prysmFunction,
1192
+ badge: parsedPrysmBadge
1193
+ }
1186
1194
  }
1187
1195
 
1188
- function parsePrysmBadge(badge, group) {
1189
- return {
1190
- function: group?.function || "",
1191
- badgeUid: badge?.uid || "",
1192
- icon: mapImage(badge?.icon, true, 80, 80, 95, null, true)?.url || "",
1193
- label: badge?.label || "",
1194
- link: badge?.link?.href || "",
1195
- type: badge?.type || ""
1196
+ function parsePrysmBadge(badge) {
1197
+ if(!isNullOrEmpty(badge)){
1198
+ return {
1199
+ uid: badge?.uid,
1200
+ icon: mapImage(badge?.icon, true, 80, 80, 95, null, true)?.url,
1201
+ label: badge?.label,
1202
+ link: badge?.link?.href,
1203
+ type: badge?.type
1204
+ }
1196
1205
  }
1206
+ return null;
1197
1207
  }
1198
1208
 
1199
1209
  module.exports = {
@@ -1243,6 +1253,6 @@ module.exports = {
1243
1253
  mapActiveEventDisclaimer,
1244
1254
  isTopCategory,
1245
1255
  mapDiscontinuedSkuReplacement,
1246
- mapPrysmBadge,
1256
+ mapPrysmData,
1247
1257
  parsePrysmBadge
1248
1258
  }