@nuskin/cs-product-lib 1.0.32 → 1.1.0-subscription-dc.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/formatKit.js +4 -1
- package/src/helpers/formatDiscounts.js +17 -0
- package/src/transformBundle.js +3 -6
package/package.json
CHANGED
package/src/formatKit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const { isNullOrEmpty, isTrue } = require('@nuskin/ns-common-lib')
|
|
1
|
+
const { isNullOrEmpty, isTrue } = require('@nuskin/ns-common-lib');
|
|
2
|
+
const { formatDiscounts } = require('./helpers/formatDiscounts');
|
|
2
3
|
const moment = require('moment')
|
|
3
4
|
|
|
4
5
|
const parseStatus = (variant) => {
|
|
@@ -206,6 +207,8 @@ const parseKit = (product, market) => {
|
|
|
206
207
|
buyOnce: kits?.availableChannels?.includes('web'),
|
|
207
208
|
subscription: kits?.availableChannels?.includes('subscription')
|
|
208
209
|
}
|
|
210
|
+
|
|
211
|
+
kits.subscriptionDiscounts = formatDiscounts(properties, 'subscriont_discounts');
|
|
209
212
|
kits.retailDiscount = properties?.retailDiscount
|
|
210
213
|
kits.wholesaleDiscount = properties?.wholesaleDiscount
|
|
211
214
|
kits.pvDiscount = properties?.pvDiscount
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { get } = require('lodash');
|
|
2
|
+
|
|
3
|
+
const formatDiscounts = (parent, key = 'discounts') => {
|
|
4
|
+
const isDiscount = key === 'discounts';
|
|
5
|
+
return {
|
|
6
|
+
retailDiscount: get(parent, `${key}.retailDiscount`, isDiscount ? get(parent, 'rtlpricedis', 0) : 0),
|
|
7
|
+
wholesaleDiscount: get(parent, `${key}.wholesaleDiscount`, isDiscount ? get(parent, 'whlpricedis', 0) : 0),
|
|
8
|
+
pvDiscount: get(parent, `${key}.pvDiscount`, isDiscount ? get(parent, 'pvdis', 0) : 0),
|
|
9
|
+
cvDiscount: get(parent, `${key}.cvDiscount`, isDiscount ? get(parent, 'cvdis', 0) : 0),
|
|
10
|
+
sbDiscount: get(parent, `${key}.sbDiscount`, isDiscount ? get(parent, 'sbdis', 0) : 0),
|
|
11
|
+
grpDiscount: get(parent, `${key}.grpDiscount`, isDiscount ? get(parent, 'grpdis', 0) : 0)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
formatDiscounts
|
|
17
|
+
};
|
package/src/transformBundle.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const helpers = require('./helpers')
|
|
2
|
+
const { formatDiscounts } = require('./helpers/formatDiscounts');
|
|
2
3
|
|
|
3
4
|
/* istanbul ignore next */
|
|
4
5
|
const transformBundle = (parent, homeUrl) => ({
|
|
@@ -14,12 +15,8 @@ const transformBundle = (parent, homeUrl) => ({
|
|
|
14
15
|
product: o?.product?.[0],
|
|
15
16
|
quantity: o.quantity
|
|
16
17
|
})),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
pvDiscount: parent?.discounts?.pvDiscount || parent?.pvdis || 0,
|
|
20
|
-
cvDiscount: parent?.discounts?.cvDiscount || parent?.cvdis || 0,
|
|
21
|
-
sbDiscount: parent?.discounts?.sbDiscount || parent?.sbdis || 0,
|
|
22
|
-
grpDiscount: parent?.discounts?.grpDiscount || parent?.grpdis || 0,
|
|
18
|
+
...formatDiscounts(parent),
|
|
19
|
+
subscriptionDiscounts: formatDiscounts(parent, 'subscription_discounts'),
|
|
23
20
|
shortDescription: parent?.short_description,
|
|
24
21
|
description: helpers?.createMarkdown(parent?.description),
|
|
25
22
|
salesLabel: parent?.sales_label,
|