@nuskin/ns-product-lib 2.18.0-brw-4218.2 → 2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +2 -2
- package/src/graph-ql/product.js +9 -12
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.19.0",
|
4
4
|
"description": "This project contains shared Product models and code between the backend and frontend.",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"scripts": {
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"@nuskin/configuration-sdk": "2.3.2",
|
23
23
|
"@nuskin/ns-common-lib": "1.4.7",
|
24
24
|
"@nuskin/ns-util": "4.5.4",
|
25
|
-
"@nuskin/product-lib": "2.2.
|
25
|
+
"@nuskin/product-lib": "2.2.1",
|
26
26
|
"axios": "1.6.7",
|
27
27
|
"axios-mock-adapter": "1.21.2",
|
28
28
|
"eslint": "^8.56.0",
|
package/src/graph-ql/product.js
CHANGED
@@ -353,13 +353,13 @@ function mapVariants(product) {
|
|
353
353
|
* @returns {array} kitBundleProducts
|
354
354
|
*/
|
355
355
|
function mapChildSKU(kitBundleProducts) {
|
356
|
-
if (!kitBundleProducts || !kitBundleProducts.kitProducts) {
|
356
|
+
if (!kitBundleProducts || !kitBundleProducts.kitProducts) /* istanbul ignore next */ {
|
357
357
|
return [];
|
358
358
|
}
|
359
359
|
const personalOffer = typeof sessionStorage !== 'undefined' && sessionStorage.getItem('personalOffer') ? JSON.parse(sessionStorage.getItem('personalOffer')) : false
|
360
360
|
return kitBundleProducts.kitProducts.map((kitProduct) => {
|
361
361
|
const { product } = kitProduct;
|
362
|
-
if (product.variants.length > 1 && typeof personalOffer === 'object') {
|
362
|
+
if (product.variants.length > 1 && typeof personalOffer === 'object') /* istanbul ignore next */ {
|
363
363
|
return product.variants.map((variant) => {
|
364
364
|
return {
|
365
365
|
productId: product.id,
|
@@ -519,6 +519,7 @@ function mapOrderTypes(availableChannels, purchaseTypes) {
|
|
519
519
|
* @param {string} status
|
520
520
|
* @returns {string} status
|
521
521
|
*/
|
522
|
+
/* istanbul ignore next */
|
522
523
|
function mapProductStatus(status) {
|
523
524
|
const { equinoxStatus } = ProductStatus;
|
524
525
|
let newStatus = '';
|
@@ -545,12 +546,16 @@ function mapProductStatus(status) {
|
|
545
546
|
return newStatus;
|
546
547
|
}
|
547
548
|
|
549
|
+
/* istanbul ignore next */
|
548
550
|
function mapPromos(product) {
|
549
551
|
if ((product.price.retailSales !== null && product.price.retailSales >= 0) || (product.price.wholesaleSales !== null && product.price.wholesaleSales >= 0)) {
|
550
552
|
if (product.pricingJson) {
|
551
553
|
const parsedPricing = JSON.parse(product.pricingJson)
|
552
|
-
|
554
|
+
let promotion = parsedPricing.promotion
|
553
555
|
if (promotion && promotion.length) {
|
556
|
+
if (promotion.length > 1) {
|
557
|
+
promotion = promotion.filter(p=>p.message !== 'Bundle discount')
|
558
|
+
}
|
554
559
|
const offerId = promotion[0].offerId || 'EQPROMO'
|
555
560
|
return {
|
556
561
|
priceMap: {[`${offerId}-WRTL`]: product.price.retailSales, [`${offerId}-WWHL`]: product.price.wholesaleSales},
|
@@ -587,17 +592,9 @@ function mapPromos(product) {
|
|
587
592
|
return { message: product.salesLabel, offerId: null, priceMap: {}, cvMap: {}, pvMap: {} }
|
588
593
|
}
|
589
594
|
return {message: null, offerId: null}
|
590
|
-
// if (isKitBundle) {
|
591
|
-
// const { pricingJson } = product
|
592
|
-
// const parsedPricing = JSON.parse(pricingJson)
|
593
|
-
// const promotion = parsedPricing.promotion
|
594
|
-
// return (promotion && promotion.length >= 1) ? { message: promotion[0].message, offerId: promotion[0].offerId } : { message: '', offerId: '' }
|
595
|
-
// } else {
|
596
|
-
// return { message: product.salesLabel || product.salesText, offerId: product.salesLabel || product.salesText }
|
597
|
-
// }
|
598
|
-
|
599
595
|
}
|
600
596
|
|
597
|
+
/* istanbul ignore next */
|
601
598
|
function parseOktaObject(okta) {
|
602
599
|
if (!okta || typeof okta !== 'string') {
|
603
600
|
return null;
|