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