@ammarkhalidfarooq/dashboard-package 0.4.84 → 0.4.86

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
@@ -5313,11 +5313,39 @@ var OverallSection = function OverallSection(_ref) {
5313
5313
  }
5314
5314
  };
5315
5315
  var activeCampaignsData = (apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || [];
5316
- console.log("ACtive campaigns", activeCampaignsData);
5317
- var donorMix = (apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData) || {};
5318
- var totalDonorsMix = (donorMix.newDonors || 0) + (donorMix.returningDonors || 0);
5319
- var newDonorsPerc = totalDonorsMix > 0 ? Math.round(donorMix.newDonors / totalDonorsMix * 100) : 0;
5320
- var returningDonorsPerc = totalDonorsMix > 0 ? Math.round(donorMix.returningDonors / totalDonorsMix * 100) : 0;
5316
+ var donorMix = apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData;
5317
+ var newDonorsCount = 0;
5318
+ var returningDonorsCount = 0;
5319
+ var totalDonorsMix = 0;
5320
+ var newDonorsPerc = 0;
5321
+ var returningDonorsPerc = 0;
5322
+ var avgGift = 0;
5323
+ var donorMixPrev = 0;
5324
+ if (Array.isArray(donorMix)) {
5325
+ var newDonorsObj = donorMix.find(function (d) {
5326
+ return d.type === "New Donors" || d.type === "New donors";
5327
+ }) || {};
5328
+ var returningDonorsObj = donorMix.find(function (d) {
5329
+ return d.type === "Returning Donors" || d.type === "Returning";
5330
+ }) || {};
5331
+ newDonorsCount = newDonorsObj.totalDonations || 0;
5332
+ returningDonorsCount = returningDonorsObj.totalDonations || 0;
5333
+ totalDonorsMix = newDonorsCount + returningDonorsCount;
5334
+ newDonorsPerc = totalDonorsMix > 0 ? Math.round(newDonorsCount / totalDonorsMix * 100) : 0;
5335
+ returningDonorsPerc = totalDonorsMix > 0 ? Math.round(returningDonorsCount / totalDonorsMix * 100) : 0;
5336
+ var totalAmount = (newDonorsObj.totalAmount || 0) + (returningDonorsObj.totalAmount || 0);
5337
+ avgGift = totalDonorsMix > 0 ? Number((totalAmount / totalDonorsMix).toFixed(2)) : 0;
5338
+ donorMixPrev = (apiData === null || apiData === void 0 ? void 0 : apiData.donorMixPrev) || 0;
5339
+ } else if (donorMix && _typeof(donorMix) === "object") {
5340
+ newDonorsCount = donorMix.newDonors || 0;
5341
+ returningDonorsCount = donorMix.returningDonors || 0;
5342
+ totalDonorsMix = newDonorsCount + returningDonorsCount;
5343
+ newDonorsPerc = totalDonorsMix > 0 ? Math.round(newDonorsCount / totalDonorsMix * 100) : 0;
5344
+ returningDonorsPerc = totalDonorsMix > 0 ? Math.round(returningDonorsCount / totalDonorsMix * 100) : 0;
5345
+ avgGift = donorMix.avgGift || 0;
5346
+ donorMixPrev = donorMix.donorMixPrev || 0;
5347
+ }
5348
+ console.log("DONOR MIX", donorMix);
5321
5349
  var renderCard = function renderCard(title) {
5322
5350
  return /*#__PURE__*/jsx(MetricCard
5323
5351
  // key={title}
@@ -5637,8 +5665,6 @@ var OverallSection = function OverallSection(_ref) {
5637
5665
  value: selectedInfo.value,
5638
5666
  trend: selectedInfo.subValue
5639
5667
  });
5640
- console.log("Donation Type Data", donationTypeData);
5641
- console.log("API DATA", apiData);
5642
5668
  return /*#__PURE__*/jsxs(Fragment, {
5643
5669
  children: [/*#__PURE__*/jsx(Box, {
5644
5670
  sx: {
@@ -5716,22 +5742,22 @@ var OverallSection = function OverallSection(_ref) {
5716
5742
  children: /*#__PURE__*/jsx(DonorMixCard, {
5717
5743
  title: "Donor mix",
5718
5744
  subtitle: "Acquisition vs retention",
5719
- series: [donorMix.newDonors || 0, donorMix.returningDonors || 0],
5745
+ series: [newDonorsCount, returningDonorsCount],
5720
5746
  labels: ["New donors", "Returning"],
5721
5747
  colors: ["rgb(99, 99, 230)", "#10B981"],
5722
5748
  centerLabel: "donors",
5723
5749
  centerValue: totalDonorsMix.toString(),
5724
5750
  items: [{
5725
5751
  label: "New donors",
5726
- val: "".concat(donorMix.newDonors || 0, " \xB7 ").concat(newDonorsPerc, "%"),
5752
+ val: "".concat(newDonorsCount, " \xB7 ").concat(newDonorsPerc, "%"),
5727
5753
  color: "rgb(99, 99, 230)"
5728
5754
  }, {
5729
5755
  label: "Returning",
5730
- val: "".concat(donorMix.returningDonors || 0, " \xB7 ").concat(returningDonorsPerc, "%"),
5756
+ val: "".concat(returningDonorsCount, " \xB7 ").concat(returningDonorsPerc, "%"),
5731
5757
  color: "#10B981"
5732
5758
  }],
5733
- bottomSummaryValue: "$".concat(donorMix.avgGift || 0),
5734
- bottomSummaryTrend: "".concat(donorMix.donorMixPrev || 0, "% vs ").concat(dateName || "last month"),
5759
+ bottomSummaryValue: "$".concat(avgGift),
5760
+ bottomSummaryTrend: "".concat(donorMixPrev, "% vs ").concat(dateName || "last month"),
5735
5761
  sx: {
5736
5762
  width: "100%"
5737
5763
  }