@ammarkhalidfarooq/dashboard-package 0.4.87 → 0.4.89

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/dist/index.cjs.js CHANGED
@@ -4811,7 +4811,14 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
4811
4811
  var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref3) {
4812
4812
  var sx = _ref3.sx,
4813
4813
  donorGeographyData = _ref3.donorGeographyData;
4814
- var data = donorGeographyData || [];
4814
+ var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || [];
4815
+ var data = rawCountries.map(function (item) {
4816
+ return {
4817
+ country: item.countryName || item.country || "Unknown",
4818
+ percentage: typeof item.percentage === "number" ? item.percentage : 0,
4819
+ value: item.donations !== undefined ? item.donations : item.value || 0
4820
+ };
4821
+ });
4815
4822
  return /*#__PURE__*/jsxRuntime.jsxs(material.Card, {
4816
4823
  sx: _objectSpread2({
4817
4824
  bgcolor: "#fff",
@@ -4889,7 +4896,35 @@ var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref3) {
4889
4896
  };
4890
4897
 
4891
4898
  var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
4892
- var sx = _ref.sx;
4899
+ var sx = _ref.sx,
4900
+ _ref$refundsChargebac = _ref.refundsChargebacksData,
4901
+ refundsChargebacksData = _ref$refundsChargebac === void 0 ? {} : _ref$refundsChargebac;
4902
+ var _refundsChargebacksDa = refundsChargebacksData.refundRate,
4903
+ refundRate = _refundsChargebacksDa === void 0 ? 0 : _refundsChargebacksDa,
4904
+ _refundsChargebacksDa2 = refundsChargebacksData.chargebackRate,
4905
+ chargebackRate = _refundsChargebacksDa2 === void 0 ? 0 : _refundsChargebacksDa2,
4906
+ _refundsChargebacksDa3 = refundsChargebacksData.totalRefundedAmount,
4907
+ totalRefundedAmount = _refundsChargebacksDa3 === void 0 ? 0 : _refundsChargebacksDa3,
4908
+ _refundsChargebacksDa4 = refundsChargebacksData.totalRefunds,
4909
+ totalRefunds = _refundsChargebacksDa4 === void 0 ? 0 : _refundsChargebacksDa4,
4910
+ _refundsChargebacksDa5 = refundsChargebacksData.totalChargebacks,
4911
+ totalChargebacks = _refundsChargebacksDa5 === void 0 ? 0 : _refundsChargebacksDa5,
4912
+ _refundsChargebacksDa6 = refundsChargebacksData.growthPercentage,
4913
+ growthPercentage = _refundsChargebacksDa6 === void 0 ? 0 : _refundsChargebacksDa6;
4914
+ refundsChargebacksData.totalRevenue;
4915
+ var _refundsChargebacksDa8 = refundsChargebacksData.chartData,
4916
+ chartData = _refundsChargebacksDa8 === void 0 ? [] : _refundsChargebacksDa8;
4917
+ var categories = chartData.map(function (item) {
4918
+ return item.date;
4919
+ });
4920
+ var refundSeries = chartData.map(function (item) {
4921
+ return parseFloat((item.refundRate || 0).toFixed(2));
4922
+ });
4923
+ var chargebackSeries = chartData.map(function (item) {
4924
+ return parseFloat((item.chargebackRate || 0).toFixed(2));
4925
+ });
4926
+ var maxVal = Math.max.apply(Math, _toConsumableArray(chargebackSeries).concat(_toConsumableArray(refundSeries), [1]));
4927
+ var yAxisMax = Math.ceil(maxVal * 1.2);
4893
4928
  var chartOptions = {
4894
4929
  chart: {
4895
4930
  type: "area",
@@ -4915,13 +4950,13 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
4915
4950
  type: "gradient",
4916
4951
  gradient: {
4917
4952
  shadeIntensity: 1,
4918
- opacityFrom: 0.45,
4919
- opacityTo: 0.05,
4953
+ opacityFrom: 0.35,
4954
+ opacityTo: 0.02,
4920
4955
  stops: [20, 100]
4921
4956
  }
4922
4957
  },
4923
4958
  xaxis: {
4924
- categories: ["Apr 5", "Apr 12", "Apr 19", "Apr 26", "May 4"],
4959
+ categories: categories,
4925
4960
  axisBorder: {
4926
4961
  show: false
4927
4962
  },
@@ -4929,23 +4964,25 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
4929
4964
  show: false
4930
4965
  },
4931
4966
  labels: {
4967
+ show: categories.length <= 15,
4968
+ rotate: -45,
4932
4969
  style: {
4933
4970
  colors: "rgba(0, 0, 0, 0.4)",
4934
- fontSize: "12px"
4971
+ fontSize: "10px"
4935
4972
  }
4936
4973
  }
4937
4974
  },
4938
4975
  yaxis: {
4939
4976
  min: 0,
4940
- max: 2,
4941
- tickAmount: 2,
4977
+ max: yAxisMax,
4978
+ tickAmount: 4,
4942
4979
  labels: {
4943
4980
  formatter: function formatter(val) {
4944
- return "".concat(val, "%");
4981
+ return "".concat(parseFloat(val.toFixed(1)), "%");
4945
4982
  },
4946
4983
  style: {
4947
4984
  colors: "rgba(0, 0, 0, 0.4)",
4948
- fontSize: "12px"
4985
+ fontSize: "11px"
4949
4986
  }
4950
4987
  }
4951
4988
  },
@@ -4956,6 +4993,10 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
4956
4993
  lines: {
4957
4994
  show: true
4958
4995
  }
4996
+ },
4997
+ padding: {
4998
+ left: 0,
4999
+ right: 0
4959
5000
  }
4960
5001
  },
4961
5002
  colors: ["#F59E0B", "#EF4444"],
@@ -4975,7 +5016,6 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
4975
5016
  fontSize: "10px",
4976
5017
  fontWeight: 700
4977
5018
  },
4978
- // text: "1% chargeback threshold",
4979
5019
  position: "left",
4980
5020
  offsetY: -10,
4981
5021
  offsetX: 10
@@ -4983,20 +5023,27 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
4983
5023
  }]
4984
5024
  },
4985
5025
  tooltip: {
5026
+ shared: true,
4986
5027
  y: {
4987
5028
  formatter: function formatter(val) {
4988
- return "".concat(val, "%");
5029
+ return "".concat(parseFloat(val.toFixed(2)), "%");
4989
5030
  }
4990
5031
  }
4991
5032
  }
4992
5033
  };
4993
5034
  var series = [{
4994
5035
  name: "Refunds",
4995
- data: [1.2, 0.9, 1.3, 0.8, 1.5, 0.9, 0.7, 0.9, 0.8]
5036
+ data: refundSeries
4996
5037
  }, {
4997
5038
  name: "Chargebacks",
4998
- data: [0.1, 0.2, 0.1, 0.15, 0.1, 0.2, 0.1, 0.15, 0.1]
5039
+ data: chargebackSeries
4999
5040
  }];
5041
+ var fmt = function fmt(n) {
5042
+ var _n$toFixed;
5043
+ return n >= 1000 ? "".concat((n / 1000).toFixed(1), "k") : parseFloat((_n$toFixed = n === null || n === void 0 ? void 0 : n.toFixed(2)) !== null && _n$toFixed !== void 0 ? _n$toFixed : 0).toString();
5044
+ };
5045
+ var growthColor = growthPercentage > 0 ? "#EF4444" : growthPercentage < 0 ? "#22C55E" : "rgba(0,0,0,0.4)";
5046
+ var growthLabel = growthPercentage > 0 ? "\u25B2 ".concat(growthPercentage.toFixed(1), "%") : growthPercentage < 0 ? "\u25BC ".concat(Math.abs(growthPercentage).toFixed(1), "%") : "stable";
5000
5047
  return /*#__PURE__*/jsxRuntime.jsxs(material.Card, {
5001
5048
  sx: _objectSpread2({
5002
5049
  bgcolor: "#fff",
@@ -5004,7 +5051,6 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
5004
5051
  border: "1px solid #f0f0f0",
5005
5052
  boxShadow: "0 4px 24px rgba(0,0,0,0.06)",
5006
5053
  p: 3,
5007
- // height: "100%",
5008
5054
  display: "flex",
5009
5055
  flexDirection: "column"
5010
5056
  }, sx),
@@ -5032,9 +5078,9 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
5032
5078
  sx: {
5033
5079
  display: "flex",
5034
5080
  gap: 2,
5035
- // mt: 0.5,
5036
5081
  mb: 0.75,
5037
- flexWrap: "wrap"
5082
+ flexWrap: "wrap",
5083
+ mt: 1
5038
5084
  },
5039
5085
  children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5040
5086
  sx: {
@@ -5065,24 +5111,23 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
5065
5111
  fontWeight: 500
5066
5112
  },
5067
5113
  children: "Refunds"
5068
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5114
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
5069
5115
  sx: {
5070
5116
  fontSize: "13px",
5071
5117
  fontWeight: 600,
5072
5118
  color: "#000"
5073
5119
  },
5074
- children: "0.8%"
5120
+ children: [refundRate.toFixed(2), "%"]
5075
5121
  })]
5076
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5122
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
5077
5123
  sx: {
5078
5124
  fontSize: "12px",
5079
- fontWeight: 700,
5080
- color: "#22C55E",
5125
+ fontWeight: 600,
5126
+ color: "rgba(0,0,0,0.4)",
5081
5127
  lineHeight: 1.2,
5082
- mt: 0.2,
5083
- ml: "-14px"
5128
+ mt: 0.2
5084
5129
  },
5085
- children: "\u25BC 0.3pp"
5130
+ children: ["$", fmt(totalRefundedAmount), " refunded"]
5086
5131
  })]
5087
5132
  })]
5088
5133
  }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
@@ -5114,39 +5159,38 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
5114
5159
  fontWeight: 500
5115
5160
  },
5116
5161
  children: "Chargebacks"
5117
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5162
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
5118
5163
  sx: {
5119
5164
  fontSize: "13px",
5120
5165
  fontWeight: 600,
5121
5166
  color: "#000"
5122
5167
  },
5123
- children: "0.1%"
5168
+ children: [chargebackRate.toFixed(2), "%"]
5124
5169
  })]
5125
5170
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5126
5171
  sx: {
5127
5172
  fontSize: "12px",
5128
- color: "rgba(0, 0, 0, 0.4)",
5129
- fontWeight: 500,
5173
+ fontWeight: 600,
5174
+ color: growthColor,
5130
5175
  lineHeight: 1.2,
5131
- mt: 0.2,
5132
- ml: "-14px"
5176
+ mt: 0.2
5133
5177
  },
5134
- children: "stable"
5178
+ children: growthLabel
5135
5179
  })]
5136
5180
  })]
5137
5181
  })]
5138
5182
  }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5139
5183
  sx: {
5140
- mb: 0
5184
+ mb: 0.5
5141
5185
  },
5142
- children: /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5186
+ children: /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
5143
5187
  sx: {
5144
5188
  fontSize: "12px",
5145
5189
  color: "rgba(0, 0, 0, 0.3)",
5146
5190
  fontWeight: 500,
5147
5191
  textAlign: "left"
5148
5192
  },
5149
- children: "$1,927 refunded \xB7 $215 disputed \xB7 0 cases total"
5193
+ children: ["$", fmt(totalRefundedAmount), " refunded \xB7 ", totalChargebacks, " chargebacks \xB7 ", totalRefunds, " refunds"]
5150
5194
  })
5151
5195
  }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5152
5196
  sx: {
@@ -5242,11 +5286,12 @@ var OverallSection = function OverallSection(_ref) {
5242
5286
  activeMetric = _useState2[0],
5243
5287
  setActiveMetric = _useState2[1];
5244
5288
  var donationTypeData = (apiData === null || apiData === void 0 ? void 0 : apiData.recurringBarChartData) || [];
5245
- var donorGeographyData = (apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography1) || [];
5289
+ var donorGeographyData = (apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography) || [];
5246
5290
  var trafficSourceData = (apiData === null || apiData === void 0 ? void 0 : apiData.trafficSource1) || [];
5247
5291
  var orderBumpData = (apiData === null || apiData === void 0 ? void 0 : apiData.orderBumpData1) || [];
5248
5292
  var upsellData = (apiData === null || apiData === void 0 ? void 0 : apiData.upsellData1) || [];
5249
5293
  var downsellData = (apiData === null || apiData === void 0 ? void 0 : apiData.downsellData1) || [];
5294
+ (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || [];
5250
5295
  var allCharts = [].concat(_toConsumableArray(primaryCharts), _toConsumableArray(secondaryCharts), _toConsumableArray(tertiaryCharts), _toConsumableArray(quaternaryCharts));
5251
5296
  var getExtendedCharts = function getExtendedCharts() {
5252
5297
  var charts = _toConsumableArray(allCharts);