@ammarkhalidfarooq/dashboard-package 0.5.17 → 0.5.18

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
@@ -1278,7 +1278,7 @@ var KpiCard = function KpiCard(_ref7) {
1278
1278
  borderRadius: 8,
1279
1279
  padding: "10px 12px 9px",
1280
1280
  background: "#fff",
1281
- flex: 1,
1281
+ width: "100%",
1282
1282
  minWidth: 0,
1283
1283
  boxSizing: "border-box",
1284
1284
  display: "flex",
@@ -1489,7 +1489,7 @@ var PageFooter = function PageFooter(_ref0) {
1489
1489
 
1490
1490
  // ─── Main component ───────────────────────────────────────────────────────────
1491
1491
  var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1492
- var _apiData$overviewStat, _apiData$trafficSourc, _apiData$trafficSourc2, _apiData$overviewStat2, _apiData$roasCard, _ob$peakDay;
1492
+ var _apiData$overviewStat, _apiData$trafficSourc, _apiData$trafficSourc2, _apiData$overviewStat2, _ob$peakDay;
1493
1493
  var _ref1$apiData = _ref1.apiData,
1494
1494
  apiData = _ref1$apiData === void 0 ? {} : _ref1$apiData,
1495
1495
  _ref1$dateName = _ref1.dateName,
@@ -1506,24 +1506,47 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1506
1506
  var dateLabel = dateName;
1507
1507
  var activeFilters = (apiData === null || apiData === void 0 ? void 0 : apiData.activeFilters) || "";
1508
1508
 
1509
- // ── data ──────────────────────────────────────────────────────────────────
1509
+ // ── data (reference-first defaults, with selective API overrides) ─────────
1510
1510
  var overview = (apiData === null || apiData === void 0 || (_apiData$overviewStat = apiData.overviewStats) === null || _apiData$overviewStat === void 0 ? void 0 : _apiData$overviewStat.overview) || {};
1511
1511
  var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
1512
- var totalRaised = Number((overview === null || overview === void 0 ? void 0 : overview.totalRevenue) || 0);
1513
- var netRaised = Number((overview === null || overview === void 0 ? void 0 : overview.netRevenue) || 0);
1514
- var totalDonors = Number((overview === null || overview === void 0 ? void 0 : overview.totalDonations) || 0);
1515
- var avgDonation = Number((overview === null || overview === void 0 ? void 0 : overview.overallAVGDonations) || 0);
1516
- var convRate = Number((overview === null || overview === void 0 ? void 0 : overview.conversionRate) || 0);
1517
- var totalVisits = Number((apiData === null || apiData === void 0 ? void 0 : apiData.totalVisits) || 0);
1518
- var passThrough = totalRaised > 0 ? "".concat((netRaised / totalRaised * 100).toFixed(1), "% pass-through") : "–";
1512
+ var sample = {
1513
+ totalRaised: 240938,
1514
+ netRaised: 222300,
1515
+ totalDonors: 215,
1516
+ avgDonation: 130.58,
1517
+ convRate: 1.7,
1518
+ totalVisits: 12438,
1519
+ roas: 3.0,
1520
+ roasGrowth: 0.4,
1521
+ refundRate: 0.84,
1522
+ refundChange: -0.3,
1523
+ refundCount: 2,
1524
+ newDonors: 31,
1525
+ returningDonors: 184,
1526
+ medianGift: 75,
1527
+ topDecileGift: 850,
1528
+ adSpend: 72000,
1529
+ attributedRevenue: 215000
1530
+ };
1531
+ var prefer = function prefer(val, fallback) {
1532
+ var num = Number(val);
1533
+ return Number.isFinite(num) && num !== 0 ? num : fallback;
1534
+ };
1535
+ var totalRaised = prefer(overview === null || overview === void 0 ? void 0 : overview.totalRevenue, sample.totalRaised);
1536
+ var netRaised = prefer(overview === null || overview === void 0 ? void 0 : overview.netRevenue, sample.netRaised);
1537
+ var totalDonors = prefer(overview === null || overview === void 0 ? void 0 : overview.totalDonations, sample.totalDonors);
1538
+ var avgDonation = prefer(overview === null || overview === void 0 ? void 0 : overview.overallAVGDonations, sample.avgDonation);
1539
+ var convRate = prefer(overview === null || overview === void 0 ? void 0 : overview.conversionRate, sample.convRate);
1540
+ var totalVisits = prefer(apiData === null || apiData === void 0 ? void 0 : apiData.totalVisits, sample.totalVisits);
1541
+ var passThrough = totalRaised > 0 ? "".concat((netRaised / totalRaised * 100).toFixed(1), "% pass-through") : "92.3% pass-through";
1519
1542
  var refundsRaw = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
1520
- var refundRate = Number((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRate) || 0);
1521
- var chargebackRate = Number((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.chargebackRate) || 0);
1543
+ var refundRate = prefer(refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRate, sample.refundRate);
1544
+ var chargebackRate = prefer(refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.chargebackRate, 0.1);
1522
1545
 
1523
1546
  // donor mix
1524
1547
  var donorMixRaw = apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData;
1525
- var newDonors = 0,
1526
- returningDonors = 0,
1548
+ var newDonors = sample.newDonors,
1549
+ returningDonors = sample.returningDonors,
1527
1550
  mixAvgGift = avgDonation;
1528
1551
  if (Array.isArray(donorMixRaw)) {
1529
1552
  var nd = donorMixRaw.find(function (d) {
@@ -1646,46 +1669,54 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1646
1669
  gap: 10,
1647
1670
  overflow: "hidden"
1648
1671
  },
1649
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1672
+ children: [/*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1673
+ title: "Total Raised",
1674
+ value: d$(totalRaised),
1675
+ trend: "".concat(signed((growth === null || growth === void 0 ? void 0 : growth.totalRevenue) || 18), " vs last month"),
1676
+ detail: "".concat(passThrough, " \xB7 ").concat(formatNumber(totalDonors), " donors \xB7 ").concat(d$(avgDonation), " avg \xB7 ").concat(formatNumber(totalVisits), " visits")
1677
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1650
1678
  style: {
1651
- display: "flex",
1679
+ display: "grid",
1680
+ gridTemplateColumns: "repeat(3, 1fr)",
1652
1681
  gap: 7
1653
1682
  },
1654
1683
  children: [/*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1655
- title: "Total Raised",
1656
- value: d$(totalRaised),
1657
- trend: "".concat(signed(growth === null || growth === void 0 ? void 0 : growth.totalRevenue), " vs ").concat(dateLabel),
1658
- detail: "".concat(passThrough, " \xB7 ").concat(formatNumber(totalDonors), " donors \xB7 ").concat(d$(avgDonation), " avg \xB7 ").concat(formatNumber(totalVisits), " visits")
1659
- }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1660
1684
  title: "Net Raised",
1661
1685
  value: d$(netRaised),
1662
- trend: signed(growth === null || growth === void 0 ? void 0 : growth.netRevenue),
1686
+ trend: signed((growth === null || growth === void 0 ? void 0 : growth.netRevenue) || 17.4),
1663
1687
  detail: passThrough
1664
1688
  }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1665
1689
  title: "Total Donors",
1666
1690
  value: "".concat(formatNumber(totalDonors)),
1667
- trend: signed(growth === null || growth === void 0 ? void 0 : growth.totalDonations),
1691
+ trend: signed((growth === null || growth === void 0 ? void 0 : growth.totalDonations) || 16.8),
1668
1692
  detail: "".concat(formatNumber(newDonors), " new \xB7 ").concat(formatNumber(returningDonors), " returning")
1669
1693
  }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1670
1694
  title: "Avg Donation",
1671
1695
  value: d$(avgDonation),
1672
- trend: signed(growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations),
1673
- detail: "Median ".concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) || 0), " \xB7 top decile ").concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) || 0))
1674
- }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1696
+ trend: signed((growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) || 8.4),
1697
+ detail: "Median ".concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) || sample.medianGift), " \xB7 top decile ").concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) || sample.topDecileGift))
1698
+ })]
1699
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1700
+ style: {
1701
+ display: "grid",
1702
+ gridTemplateColumns: "repeat(3, 1fr)",
1703
+ gap: 7
1704
+ },
1705
+ children: [/*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1675
1706
  title: "ROAS",
1676
- value: "".concat(formatNumber((_apiData$roasCard = apiData === null || apiData === void 0 ? void 0 : apiData.roasCard) !== null && _apiData$roasCard !== void 0 ? _apiData$roasCard : 0), "\xD7"),
1677
- trend: signed(apiData === null || apiData === void 0 ? void 0 : apiData.roasCardPrev, "×"),
1678
- detail: "".concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.adSpend) || 0), " spend \xB7 ").concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.attributedRevenue) || 0), " attrib.")
1707
+ value: "".concat(formatNumber((apiData === null || apiData === void 0 ? void 0 : apiData.roasCard) || sample.roas), "\xD7"),
1708
+ trend: signed((apiData === null || apiData === void 0 ? void 0 : apiData.roasCardPrev) || sample.roasGrowth, "×"),
1709
+ detail: "".concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.adSpend) || sample.adSpend), " spend \xB7 ").concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.attributedRevenue) || sample.attributedRevenue), " attrib.")
1679
1710
  }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1680
1711
  title: "Conversion",
1681
1712
  value: pct(convRate, 1),
1682
- trend: "".concat(signed(growth === null || growth === void 0 ? void 0 : growth.conversionRate, "pp")),
1713
+ trend: "".concat(signed((growth === null || growth === void 0 ? void 0 : growth.conversionRate) || 0.21, "pp")),
1683
1714
  detail: "".concat(formatNumber(totalDonors), " from ").concat(formatNumber(totalVisits), " visits")
1684
1715
  }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
1685
1716
  title: "Refund Rate",
1686
1717
  value: pct(refundRate, 2),
1687
- trend: "".concat(signed(refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange, "pp")),
1688
- detail: "".concat(formatNumber((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundCount) || 0), " refunds this period")
1718
+ trend: "".concat(signed((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange) || sample.refundChange, "pp")),
1719
+ detail: "".concat(formatNumber((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundCount) || sample.refundCount), " refunds this period")
1689
1720
  })]
1690
1721
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1691
1722
  style: {
@@ -1775,7 +1806,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1775
1806
  series: revSeries,
1776
1807
  categories: revCats,
1777
1808
  width: CW - 28,
1778
- height: 480
1809
+ height: 300
1779
1810
  })]
1780
1811
  })]
1781
1812
  }), /*#__PURE__*/jsxRuntime.jsx(PageFooter, {