@ammarkhalidfarooq/dashboard-package 0.4.84 → 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
@@ -5314,10 +5314,38 @@ var OverallSection = function OverallSection(_ref) {
5314
5314
  };
5315
5315
  var activeCampaignsData = (apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || [];
5316
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;
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
+ }
5321
5349
  var renderCard = function renderCard(title) {
5322
5350
  return /*#__PURE__*/jsx(MetricCard
5323
5351
  // key={title}
@@ -5716,22 +5744,22 @@ var OverallSection = function OverallSection(_ref) {
5716
5744
  children: /*#__PURE__*/jsx(DonorMixCard, {
5717
5745
  title: "Donor mix",
5718
5746
  subtitle: "Acquisition vs retention",
5719
- series: [donorMix.newDonors || 0, donorMix.returningDonors || 0],
5747
+ series: [newDonorsCount, returningDonorsCount],
5720
5748
  labels: ["New donors", "Returning"],
5721
5749
  colors: ["rgb(99, 99, 230)", "#10B981"],
5722
5750
  centerLabel: "donors",
5723
5751
  centerValue: totalDonorsMix.toString(),
5724
5752
  items: [{
5725
5753
  label: "New donors",
5726
- val: "".concat(donorMix.newDonors || 0, " \xB7 ").concat(newDonorsPerc, "%"),
5754
+ val: "".concat(newDonorsCount, " \xB7 ").concat(newDonorsPerc, "%"),
5727
5755
  color: "rgb(99, 99, 230)"
5728
5756
  }, {
5729
5757
  label: "Returning",
5730
- val: "".concat(donorMix.returningDonors || 0, " \xB7 ").concat(returningDonorsPerc, "%"),
5758
+ val: "".concat(returningDonorsCount, " \xB7 ").concat(returningDonorsPerc, "%"),
5731
5759
  color: "#10B981"
5732
5760
  }],
5733
- bottomSummaryValue: "$".concat(donorMix.avgGift || 0),
5734
- bottomSummaryTrend: "".concat(donorMix.donorMixPrev || 0, "% vs ").concat(dateName || "last month"),
5761
+ bottomSummaryValue: "$".concat(avgGift),
5762
+ bottomSummaryTrend: "".concat(donorMixPrev, "% vs ").concat(dateName || "last month"),
5735
5763
  sx: {
5736
5764
  width: "100%"
5737
5765
  }