@nuskin/cs-product-lib 1.0.6 → 1.0.7
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 +13 -13
- package/src/formatKit.js +3 -0
- package/src/formatProduct.js +2 -2
- package/src/transformBundle.js +1 -1
package/package.json
CHANGED
package/src/csProduct.js
CHANGED
|
@@ -156,33 +156,33 @@ const csProduct = (props) => {
|
|
|
156
156
|
|
|
157
157
|
const formatProductWithSchema = (products = []) => {
|
|
158
158
|
return products?.map((product) => {
|
|
159
|
-
const
|
|
160
|
-
|
|
159
|
+
const formattedProduct = formatProduct(product, homeUrl)
|
|
160
|
+
formattedProduct.variants = formattedProduct?.variants?.map(
|
|
161
161
|
(variant) => formatVariant(variant)
|
|
162
162
|
)
|
|
163
|
-
return
|
|
163
|
+
return formattedProduct
|
|
164
164
|
})
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
const formatBundleWithSchema = (bundles = []) => {
|
|
168
168
|
return bundles?.map((bundle) => {
|
|
169
|
-
const
|
|
169
|
+
const formattedBundle = transformBundle(bundle, homeUrl)
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
formattedBundle.requiredProducts = formattedBundle?.requiredProducts?.map(
|
|
172
172
|
({product, quantity}) => {
|
|
173
|
-
const [
|
|
174
|
-
return {product :
|
|
173
|
+
const [formattedProduct] = formatProductWithSchema([product])
|
|
174
|
+
return {product : formattedProduct, quantity}
|
|
175
175
|
}
|
|
176
176
|
)
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
formattedBundle.optionalProducts = formattedBundle?.optionalProducts?.map(
|
|
179
179
|
({product, quantity}) => {
|
|
180
|
-
const [
|
|
181
|
-
return {product :
|
|
180
|
+
const [formattedProduct] = formatProductWithSchema([product])
|
|
181
|
+
return {product : formattedProduct, quantity}
|
|
182
182
|
}
|
|
183
183
|
)
|
|
184
184
|
|
|
185
|
-
return
|
|
185
|
+
return formattedBundle
|
|
186
186
|
})
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -419,10 +419,10 @@ const csProduct = (props) => {
|
|
|
419
419
|
|
|
420
420
|
const getProductTranslations = async (locale) => {
|
|
421
421
|
const translations = await getTranslations(locale)
|
|
422
|
-
const
|
|
422
|
+
const formattedTranslations = translations.map((translate) =>
|
|
423
423
|
formatTranslations(translate)
|
|
424
424
|
)
|
|
425
|
-
return
|
|
425
|
+
return formattedTranslations
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
const publishedProducts = async ({ locale, skip = 0, limit = 50 } = {}) => {
|
package/src/formatKit.js
CHANGED
|
@@ -91,6 +91,9 @@ const parseBundleAvailableQuantity = (product) => {
|
|
|
91
91
|
const parseKit = (product, market) => {
|
|
92
92
|
const kits = {}
|
|
93
93
|
const [properties] = product || []
|
|
94
|
+
kits.id = properties?.id
|
|
95
|
+
kits.uid = properties?.uid
|
|
96
|
+
kits.title = properties?.title
|
|
94
97
|
kits.description = properties?.description
|
|
95
98
|
kits.availableChannels = properties.availableChannels
|
|
96
99
|
kits.chargeShipping = properties.chargeShipping === 'true'
|
package/src/formatProduct.js
CHANGED
|
@@ -4,7 +4,7 @@ const { formatKit } = require('./formatKit')
|
|
|
4
4
|
|
|
5
5
|
/* istanbul ignore next */
|
|
6
6
|
const formatProduct = (parent, homeUrl) => {
|
|
7
|
-
const
|
|
7
|
+
const formattedProduct = {
|
|
8
8
|
// Each value is a function with a parameter 'parent' that is the current instance of a Product
|
|
9
9
|
// ContentStack references need to be queried separately (ie: variants)
|
|
10
10
|
id: parent.uid,
|
|
@@ -76,7 +76,7 @@ const formatProduct = (parent, homeUrl) => {
|
|
|
76
76
|
upSellProductIds: helpers?.mapUpSellProductIds(parent),
|
|
77
77
|
crossProductIds: helpers?.mapCrossProductIds(parent)
|
|
78
78
|
}
|
|
79
|
-
return formatKit(
|
|
79
|
+
return formatKit(formattedProduct)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
module.exports = {
|
package/src/transformBundle.js
CHANGED
|
@@ -4,7 +4,7 @@ const helpers = require('./helpers')
|
|
|
4
4
|
const transformBundle = (parent, homeUrl) => ({
|
|
5
5
|
id: parent.bundle_id,
|
|
6
6
|
uid: parent.uid,
|
|
7
|
-
title: parent.
|
|
7
|
+
title: parent.title,
|
|
8
8
|
type: parent.type,
|
|
9
9
|
requiredProducts: parent.required_products?.map((r) => ({
|
|
10
10
|
product: r?.product?.[0],
|