@artisan-commerce/analytics-rn 0.3.0-canary.64 → 0.3.0-canary.65

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.
@@ -40,7 +40,7 @@ const getState$2 = () => {
40
40
 
41
41
  var name = "@artisan-commerce/analytics-rn";
42
42
  var description = "Artisn commerce analytics react native library";
43
- var version = "0.3.0-canary.64";
43
+ var version = "0.3.0-canary.65";
44
44
  var main = "./dist/bundle.esm.js";
45
45
  var module = "./dist/bundle.esm.js";
46
46
  var types = "./dist/bundle.d.ts";
@@ -82,9 +82,9 @@ var dependencies = {
82
82
  "snake-case": "^3.0.4"
83
83
  };
84
84
  var devDependencies = {
85
- "@artisan-commerce/products": "0.9.0-canary.40",
86
- "@artisan-commerce/shopping-cart": "0.12.0-canary.60",
87
- "@artisan-commerce/types": "0.14.0-canary.31",
85
+ "@artisan-commerce/products": "0.9.0-canary.41",
86
+ "@artisan-commerce/shopping-cart": "0.12.0-canary.61",
87
+ "@artisan-commerce/types": "0.14.0-canary.32",
88
88
  "@babel/core": "^7.13.15",
89
89
  "@babel/preset-env": "^7.10.4",
90
90
  "@babel/preset-react": "^7.10.4",
@@ -103,7 +103,7 @@ var peerDependencies = {
103
103
  react: ">=16.8.6",
104
104
  "react-native-fbsdk-next": "*"
105
105
  };
106
- var gitHead = "de13038c82f26138ab893018f60d3d3bd2a37c1f";
106
+ var gitHead = "ad88ffa2a383481b53bce14414e6a0b6c2942f3e";
107
107
  var packageJSON = {
108
108
  name: name,
109
109
  description: description,
@@ -1508,13 +1508,16 @@ const applyBenefits = (additionalInfo, benefits, shoppingCartTotals) => {
1508
1508
  }
1509
1509
  const benefitsValues = Object.values(benefits);
1510
1510
  return benefitsValues.reduce((acc, benefit) => {
1511
- if (benefit.type === "DISCOUNT") {
1512
- return applyBenefitByDiscount(benefit, acc, additionalInfo);
1511
+ if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
1512
+ return applyBenefitByDiscountPercentage(benefit, acc, additionalInfo);
1513
+ }
1514
+ if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
1515
+ return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
1513
1516
  }
1514
1517
  return acc;
1515
1518
  }, shoppingCartTotals);
1516
1519
  };
1517
- const applyBenefitByDiscount = (benefit, shoppingCartTotals, additionalInfo) => {
1520
+ const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additionalInfo) => {
1518
1521
  const { subtotal, total: prevTotal } = shoppingCartTotals;
1519
1522
  const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
1520
1523
  const discountPercentage = benefit.discountPercentage * 0.01;
@@ -1537,6 +1540,26 @@ const applyBenefitByDiscount = (benefit, shoppingCartTotals, additionalInfo) =>
1537
1540
  total: newTotal
1538
1541
  });
1539
1542
  };
1543
+ const applyBenefitByDiscountFixed = (benefit, shoppingCartTotals, additionalInfo) => {
1544
+ const { total: prevTotal } = shoppingCartTotals;
1545
+ const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
1546
+ const discountFixed = Number(benefit.discountFixed);
1547
+ if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
1548
+ const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
1549
+ const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
1550
+ const newTotal2 = (copayment - discountFixed).toFixed(4);
1551
+ return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
1552
+ totalDiscounts: newTotalDiscounts2,
1553
+ total: Number(newTotal2)
1554
+ });
1555
+ }
1556
+ const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
1557
+ const newTotal = prevTotal - discountFixed;
1558
+ return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
1559
+ totalDiscounts: newTotalDiscounts,
1560
+ total: newTotal
1561
+ });
1562
+ };
1540
1563
 
1541
1564
  const isBaseProduct = (product) => {
1542
1565
  const { attributes, description, name } = product;