@ammarkhalidfarooq/dashboard-package 0.4.83 → 0.4.85

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
@@ -3675,13 +3675,56 @@ var MetricDonutCard = function MetricDonutCard(_ref) {
3675
3675
  };
3676
3676
 
3677
3677
  var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
3678
- var _donationTypeData$sum, _donationTypeData$sum2, _donationTypeData$sum3, _donationTypeData$sum4, _donationTypeData$sum5, _donationTypeData$sum6;
3679
3678
  var sx = _ref.sx,
3680
- _ref$donationTypeData = _ref.donationTypeData,
3681
- donationTypeData = _ref$donationTypeData === void 0 ? [] : _ref$donationTypeData;
3682
- console.log("CHART DATA", donationTypeData);
3683
- var recurringColor = (donationTypeData === null || donationTypeData === void 0 || (_donationTypeData$sum = donationTypeData.summary) === null || _donationTypeData$sum === void 0 || (_donationTypeData$sum = _donationTypeData$sum.recurring) === null || _donationTypeData$sum === void 0 ? void 0 : _donationTypeData$sum.color) || "rgb(99, 99, 230)";
3684
- var oneTimeColor = (donationTypeData === null || donationTypeData === void 0 || (_donationTypeData$sum2 = donationTypeData.summary) === null || _donationTypeData$sum2 === void 0 || (_donationTypeData$sum2 = _donationTypeData$sum2.oneTime) === null || _donationTypeData$sum2 === void 0 ? void 0 : _donationTypeData$sum2.color) || "#10B981";
3679
+ donationTypeData = _ref.donationTypeData;
3680
+ var recurringColor = "rgb(99, 99, 230)";
3681
+ var oneTimeColor = "#10B981";
3682
+ var colors = [recurringColor, oneTimeColor, "#06B6D4", "#F59E0B", "#EF4444"];
3683
+ var categories = [];
3684
+ var series = [];
3685
+ var summaries = [];
3686
+ var title = "Donation Type";
3687
+ var isDistributed = false;
3688
+ if (Array.isArray(donationTypeData) && donationTypeData.length > 0 && donationTypeData[0].totalAmount !== undefined) {
3689
+ // New array format
3690
+ categories = donationTypeData.map(function (item) {
3691
+ return item.type || "";
3692
+ });
3693
+ series = [{
3694
+ name: "Amount",
3695
+ data: donationTypeData.map(function (item) {
3696
+ return item.totalAmount || 0;
3697
+ })
3698
+ }];
3699
+ summaries = donationTypeData.map(function (item, index) {
3700
+ return {
3701
+ label: item.type || "",
3702
+ total: item.totalAmount || 0,
3703
+ color: colors[index % colors.length]
3704
+ };
3705
+ });
3706
+ isDistributed = true;
3707
+ if (donationTypeData.length === 2) {
3708
+ title = "".concat(donationTypeData[0].type, " vs ").concat(donationTypeData[1].type);
3709
+ }
3710
+ } else {
3711
+ var _dataObj$summary, _dataObj$summary2, _dataObj$summary3, _dataObj$summary4;
3712
+ // Object format or simple series array
3713
+ var dataObj = donationTypeData || {};
3714
+ categories = dataObj.categories || [];
3715
+ series = Array.isArray(donationTypeData) ? donationTypeData : dataObj.series || [];
3716
+ summaries = [{
3717
+ label: (dataObj === null || dataObj === void 0 || (_dataObj$summary = dataObj.summary) === null || _dataObj$summary === void 0 || (_dataObj$summary = _dataObj$summary.recurring) === null || _dataObj$summary === void 0 ? void 0 : _dataObj$summary.label) || "Recurring",
3718
+ total: (dataObj === null || dataObj === void 0 || (_dataObj$summary2 = dataObj.summary) === null || _dataObj$summary2 === void 0 || (_dataObj$summary2 = _dataObj$summary2.recurring) === null || _dataObj$summary2 === void 0 ? void 0 : _dataObj$summary2.total) || 0,
3719
+ color: recurringColor
3720
+ }, {
3721
+ label: (dataObj === null || dataObj === void 0 || (_dataObj$summary3 = dataObj.summary) === null || _dataObj$summary3 === void 0 || (_dataObj$summary3 = _dataObj$summary3.oneTime) === null || _dataObj$summary3 === void 0 ? void 0 : _dataObj$summary3.label) || "One-time",
3722
+ total: (dataObj === null || dataObj === void 0 || (_dataObj$summary4 = dataObj.summary) === null || _dataObj$summary4 === void 0 || (_dataObj$summary4 = _dataObj$summary4.oneTime) === null || _dataObj$summary4 === void 0 ? void 0 : _dataObj$summary4.total) || 0,
3723
+ color: oneTimeColor
3724
+ }];
3725
+ title = "Recurring vs one-time";
3726
+ isDistributed = false;
3727
+ }
3685
3728
  var chartOptions = {
3686
3729
  chart: {
3687
3730
  type: "bar",
@@ -3696,8 +3739,9 @@ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
3696
3739
  plotOptions: {
3697
3740
  bar: {
3698
3741
  horizontal: false,
3699
- columnWidth: "70%",
3742
+ columnWidth: "50%",
3700
3743
  borderRadius: 4,
3744
+ distributed: isDistributed,
3701
3745
  dataLabels: {
3702
3746
  position: "top"
3703
3747
  }
@@ -3708,10 +3752,10 @@ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
3708
3752
  formatter: function formatter(val) {
3709
3753
  return "$".concat(formatNumber(val));
3710
3754
  },
3711
- offsetY: -10,
3755
+ offsetY: -20,
3712
3756
  style: {
3713
- fontSize: "6px",
3714
- fontWeight: 400,
3757
+ fontSize: "9px",
3758
+ fontWeight: 600,
3715
3759
  colors: ["#000"]
3716
3760
  }
3717
3761
  },
@@ -3721,7 +3765,7 @@ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
3721
3765
  colors: ["transparent"]
3722
3766
  },
3723
3767
  xaxis: {
3724
- categories: (donationTypeData === null || donationTypeData === void 0 ? void 0 : donationTypeData.categories) || [],
3768
+ categories: categories,
3725
3769
  axisBorder: {
3726
3770
  show: false
3727
3771
  },
@@ -3751,7 +3795,7 @@ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
3751
3795
  fill: {
3752
3796
  opacity: 1
3753
3797
  },
3754
- colors: [recurringColor, oneTimeColor],
3798
+ colors: colors,
3755
3799
  grid: {
3756
3800
  borderColor: "#f1f1f1",
3757
3801
  strokeDashArray: 4,
@@ -3776,7 +3820,6 @@ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
3776
3820
  }
3777
3821
  }
3778
3822
  };
3779
- var series = (donationTypeData === null || donationTypeData === void 0 ? void 0 : donationTypeData.series) || [];
3780
3823
  return /*#__PURE__*/jsxRuntime.jsxs(material.Card, {
3781
3824
  sx: _objectSpread2({
3782
3825
  bgcolor: "#fff",
@@ -3800,78 +3843,53 @@ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
3800
3843
  fontSize: "18px",
3801
3844
  color: "#000"
3802
3845
  },
3803
- children: "Recurring vs one-time"
3846
+ children: title
3804
3847
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
3805
3848
  sx: {
3806
3849
  fontSize: "13px",
3807
3850
  color: "rgba(0, 0, 0, 0.4)",
3808
3851
  mt: 0
3809
3852
  },
3810
- children: "Donation type \xB7 weekly"
3853
+ children: "Donation type"
3811
3854
  })]
3812
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
3855
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
3813
3856
  sx: {
3814
3857
  display: "flex",
3815
3858
  gap: 1.5,
3816
- mt: 0.5
3859
+ mt: 0.5,
3860
+ flexWrap: "wrap"
3817
3861
  },
3818
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
3819
- sx: {
3820
- display: "flex",
3821
- alignItems: "center",
3822
- gap: 0.5
3823
- },
3824
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
3825
- sx: {
3826
- width: 8,
3827
- height: 8,
3828
- bgcolor: "rgb(99, 99, 230)",
3829
- borderRadius: "50%"
3830
- }
3831
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
3832
- sx: {
3833
- fontSize: "13px",
3834
- color: "rgba(0, 0, 0, 0.5)",
3835
- fontWeight: 500
3836
- },
3837
- children: donationTypeData === null || donationTypeData === void 0 || (_donationTypeData$sum3 = donationTypeData.summary) === null || _donationTypeData$sum3 === void 0 || (_donationTypeData$sum3 = _donationTypeData$sum3.recurring) === null || _donationTypeData$sum3 === void 0 ? void 0 : _donationTypeData$sum3.label
3838
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
3839
- sx: {
3840
- fontSize: "13px",
3841
- fontWeight: 600,
3842
- color: "#000"
3843
- },
3844
- children: ["$", formatNumber((donationTypeData === null || donationTypeData === void 0 || (_donationTypeData$sum4 = donationTypeData.summary) === null || _donationTypeData$sum4 === void 0 || (_donationTypeData$sum4 = _donationTypeData$sum4.recurring) === null || _donationTypeData$sum4 === void 0 ? void 0 : _donationTypeData$sum4.total) || 0)]
3845
- })]
3846
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
3847
- sx: {
3848
- display: "flex",
3849
- alignItems: "center",
3850
- gap: 0.5
3851
- },
3852
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
3853
- sx: {
3854
- width: 8,
3855
- height: 8,
3856
- bgcolor: "#10B981",
3857
- borderRadius: "50%"
3858
- }
3859
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
3860
- sx: {
3861
- fontSize: "13px",
3862
- color: "rgba(0, 0, 0, 0.5)",
3863
- fontWeight: 500
3864
- },
3865
- children: donationTypeData === null || donationTypeData === void 0 || (_donationTypeData$sum5 = donationTypeData.summary) === null || _donationTypeData$sum5 === void 0 || (_donationTypeData$sum5 = _donationTypeData$sum5.oneTime) === null || _donationTypeData$sum5 === void 0 ? void 0 : _donationTypeData$sum5.label
3866
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
3862
+ children: summaries.map(function (item, index) {
3863
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
3867
3864
  sx: {
3868
- fontSize: "13px",
3869
- fontWeight: 600,
3870
- color: "#000"
3865
+ display: "flex",
3866
+ alignItems: "center",
3867
+ gap: 0.5
3871
3868
  },
3872
- children: ["$", formatNumber((donationTypeData === null || donationTypeData === void 0 || (_donationTypeData$sum6 = donationTypeData.summary) === null || _donationTypeData$sum6 === void 0 || (_donationTypeData$sum6 = _donationTypeData$sum6.oneTime) === null || _donationTypeData$sum6 === void 0 ? void 0 : _donationTypeData$sum6.total) || 0)]
3873
- })]
3874
- })]
3869
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
3870
+ sx: {
3871
+ width: 8,
3872
+ height: 8,
3873
+ bgcolor: item.color,
3874
+ borderRadius: "50%"
3875
+ }
3876
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
3877
+ sx: {
3878
+ fontSize: "13px",
3879
+ color: "rgba(0, 0, 0, 0.5)",
3880
+ fontWeight: 500
3881
+ },
3882
+ children: item.label
3883
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
3884
+ sx: {
3885
+ fontSize: "13px",
3886
+ fontWeight: 600,
3887
+ color: "#000"
3888
+ },
3889
+ children: ["$", formatNumber(item.total || 0)]
3890
+ })]
3891
+ }, item.label || index);
3892
+ })
3875
3893
  })]
3876
3894
  }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
3877
3895
  sx: {
@@ -5196,7 +5214,7 @@ var OverallSection = function OverallSection(_ref) {
5196
5214
  _useState2 = _slicedToArray(_useState, 2),
5197
5215
  activeMetric = _useState2[0],
5198
5216
  setActiveMetric = _useState2[1];
5199
- var donationTypeData = (apiData === null || apiData === void 0 ? void 0 : apiData.donationTypeData1) || [];
5217
+ var donationTypeData = (apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData1) || [];
5200
5218
  var donorGeographyData = (apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography1) || [];
5201
5219
  var trafficSourceData = (apiData === null || apiData === void 0 ? void 0 : apiData.trafficSource1) || [];
5202
5220
  var orderBumpData = (apiData === null || apiData === void 0 ? void 0 : apiData.orderBumpData1) || [];
@@ -5298,10 +5316,38 @@ var OverallSection = function OverallSection(_ref) {
5298
5316
  };
5299
5317
  var activeCampaignsData = (apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || [];
5300
5318
  console.log("ACtive campaigns", activeCampaignsData);
5301
- var donorMix = (apiData === null || apiData === void 0 ? void 0 : apiData.donorMix1) || {};
5302
- var totalDonorsMix = (donorMix.newDonors || 0) + (donorMix.returningDonors || 0);
5303
- var newDonorsPerc = totalDonorsMix > 0 ? Math.round(donorMix.newDonors / totalDonorsMix * 100) : 0;
5304
- var returningDonorsPerc = totalDonorsMix > 0 ? Math.round(donorMix.returningDonors / totalDonorsMix * 100) : 0;
5319
+ var donorMix = apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData;
5320
+ var newDonorsCount = 0;
5321
+ var returningDonorsCount = 0;
5322
+ var totalDonorsMix = 0;
5323
+ var newDonorsPerc = 0;
5324
+ var returningDonorsPerc = 0;
5325
+ var avgGift = 0;
5326
+ var donorMixPrev = 0;
5327
+ if (Array.isArray(donorMix)) {
5328
+ var newDonorsObj = donorMix.find(function (d) {
5329
+ return d.type === "New Donors" || d.type === "New donors";
5330
+ }) || {};
5331
+ var returningDonorsObj = donorMix.find(function (d) {
5332
+ return d.type === "Returning Donors" || d.type === "Returning";
5333
+ }) || {};
5334
+ newDonorsCount = newDonorsObj.totalDonations || 0;
5335
+ returningDonorsCount = returningDonorsObj.totalDonations || 0;
5336
+ totalDonorsMix = newDonorsCount + returningDonorsCount;
5337
+ newDonorsPerc = totalDonorsMix > 0 ? Math.round(newDonorsCount / totalDonorsMix * 100) : 0;
5338
+ returningDonorsPerc = totalDonorsMix > 0 ? Math.round(returningDonorsCount / totalDonorsMix * 100) : 0;
5339
+ var totalAmount = (newDonorsObj.totalAmount || 0) + (returningDonorsObj.totalAmount || 0);
5340
+ avgGift = totalDonorsMix > 0 ? Number((totalAmount / totalDonorsMix).toFixed(2)) : 0;
5341
+ donorMixPrev = (apiData === null || apiData === void 0 ? void 0 : apiData.donorMixPrev) || 0;
5342
+ } else if (donorMix && _typeof(donorMix) === "object") {
5343
+ newDonorsCount = donorMix.newDonors || 0;
5344
+ returningDonorsCount = donorMix.returningDonors || 0;
5345
+ totalDonorsMix = newDonorsCount + returningDonorsCount;
5346
+ newDonorsPerc = totalDonorsMix > 0 ? Math.round(newDonorsCount / totalDonorsMix * 100) : 0;
5347
+ returningDonorsPerc = totalDonorsMix > 0 ? Math.round(returningDonorsCount / totalDonorsMix * 100) : 0;
5348
+ avgGift = donorMix.avgGift || 0;
5349
+ donorMixPrev = donorMix.donorMixPrev || 0;
5350
+ }
5305
5351
  var renderCard = function renderCard(title) {
5306
5352
  return /*#__PURE__*/jsxRuntime.jsx(MetricCard
5307
5353
  // key={title}
@@ -5700,22 +5746,22 @@ var OverallSection = function OverallSection(_ref) {
5700
5746
  children: /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
5701
5747
  title: "Donor mix",
5702
5748
  subtitle: "Acquisition vs retention",
5703
- series: [donorMix.newDonors || 0, donorMix.returningDonors || 0],
5749
+ series: [newDonorsCount, returningDonorsCount],
5704
5750
  labels: ["New donors", "Returning"],
5705
5751
  colors: ["rgb(99, 99, 230)", "#10B981"],
5706
5752
  centerLabel: "donors",
5707
5753
  centerValue: totalDonorsMix.toString(),
5708
5754
  items: [{
5709
5755
  label: "New donors",
5710
- val: "".concat(donorMix.newDonors || 0, " \xB7 ").concat(newDonorsPerc, "%"),
5756
+ val: "".concat(newDonorsCount, " \xB7 ").concat(newDonorsPerc, "%"),
5711
5757
  color: "rgb(99, 99, 230)"
5712
5758
  }, {
5713
5759
  label: "Returning",
5714
- val: "".concat(donorMix.returningDonors || 0, " \xB7 ").concat(returningDonorsPerc, "%"),
5760
+ val: "".concat(returningDonorsCount, " \xB7 ").concat(returningDonorsPerc, "%"),
5715
5761
  color: "#10B981"
5716
5762
  }],
5717
- bottomSummaryValue: "$".concat(donorMix.avgGift || 0),
5718
- bottomSummaryTrend: "".concat(donorMix.donorMixPrev || 0, "% vs ").concat(dateName || "last month"),
5763
+ bottomSummaryValue: "$".concat(avgGift),
5764
+ bottomSummaryTrend: "".concat(donorMixPrev, "% vs ").concat(dateName || "last month"),
5719
5765
  sx: {
5720
5766
  width: "100%"
5721
5767
  }