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