@ammarkhalidfarooq/dashboard-package 0.6.64 → 0.6.66

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
@@ -1329,287 +1329,6 @@ var MetricCard$1 = function MetricCard(_ref) {
1329
1329
  });
1330
1330
  };
1331
1331
 
1332
- var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
1333
- var sx = _ref.sx,
1334
- donationTypeData = _ref.donationTypeData,
1335
- _ref$exportMode = _ref.exportMode,
1336
- exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode,
1337
- _ref$subtitle = _ref.subtitle,
1338
- subtitle = _ref$subtitle === void 0 ? "Donation type" : _ref$subtitle,
1339
- chartHeight = _ref.chartHeight;
1340
- var recurringColor = "rgb(99, 99, 230)";
1341
- var oneTimeColor = "#10B981";
1342
- var colors = [recurringColor, oneTimeColor, "#06B6D4", "#F59E0B", "#EF4444"];
1343
- var categories = [];
1344
- var series = [];
1345
- var summaries = [];
1346
- var title = "Donation Type";
1347
- var isDistributed = false;
1348
- if (donationTypeData && donationTypeData.data && Array.isArray(donationTypeData.data)) {
1349
- // Time series recurring vs one-time format
1350
- categories = donationTypeData.data.map(function (item) {
1351
- return item.label || "";
1352
- });
1353
- series = [{
1354
- name: "Recurring",
1355
- data: donationTypeData.data.map(function (item) {
1356
- return item.recurring || 0;
1357
- })
1358
- }, {
1359
- name: "One-time",
1360
- data: donationTypeData.data.map(function (item) {
1361
- return item.oneTime || 0;
1362
- })
1363
- }];
1364
- summaries = [{
1365
- label: "Recurring",
1366
- total: donationTypeData.totalRecurringDonations || 0,
1367
- color: recurringColor
1368
- }, {
1369
- label: "One-time",
1370
- total: donationTypeData.totalOneTimeDonations || 0,
1371
- color: oneTimeColor
1372
- }];
1373
- title = "Recurring vs One-time";
1374
- isDistributed = false;
1375
- } else if (Array.isArray(donationTypeData) && donationTypeData.length > 0 && donationTypeData[0].totalAmount !== undefined) {
1376
- // New array format
1377
- categories = donationTypeData.map(function (item) {
1378
- return item.type || "";
1379
- });
1380
- series = [{
1381
- name: "Amount",
1382
- data: donationTypeData.map(function (item) {
1383
- return item.totalAmount || 0;
1384
- })
1385
- }];
1386
- summaries = donationTypeData.map(function (item, index) {
1387
- return {
1388
- label: item.type || "",
1389
- total: item.totalAmount || 0,
1390
- color: colors[index % colors.length]
1391
- };
1392
- });
1393
- isDistributed = true;
1394
- if (donationTypeData.length === 2) {
1395
- title = "".concat(donationTypeData[0].type, " vs ").concat(donationTypeData[1].type);
1396
- }
1397
- } else {
1398
- var _dataObj$summary, _dataObj$summary2, _dataObj$summary3, _dataObj$summary4;
1399
- // Object format, empty array, or missing data
1400
- var dataObj = donationTypeData && _typeof(donationTypeData) === "object" && !Array.isArray(donationTypeData) ? donationTypeData : {};
1401
- categories = dataObj.categories || [];
1402
- var rawSeries = dataObj.series || [];
1403
- if (rawSeries.length && categories.length) {
1404
- series = rawSeries;
1405
- } else {
1406
- series = [{
1407
- name: "Recurring",
1408
- data: []
1409
- }, {
1410
- name: "One-time",
1411
- data: []
1412
- }];
1413
- }
1414
- summaries = [{
1415
- 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",
1416
- 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,
1417
- color: recurringColor
1418
- }, {
1419
- 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",
1420
- 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,
1421
- color: oneTimeColor
1422
- }];
1423
- title = "Recurring vs one-time";
1424
- isDistributed = false;
1425
- }
1426
- var resolvedChartHeight = chartHeight !== null && chartHeight !== void 0 ? chartHeight : exportMode ? 110 : 170;
1427
- var chartOptions = {
1428
- chart: {
1429
- type: "bar",
1430
- toolbar: {
1431
- show: false
1432
- },
1433
- zoom: {
1434
- enabled: false
1435
- },
1436
- fontFamily: "Inter, sans-serif"
1437
- },
1438
- plotOptions: {
1439
- bar: {
1440
- horizontal: false,
1441
- columnWidth: exportMode ? "68%" : "75%",
1442
- borderRadius: exportMode ? 3 : 4,
1443
- distributed: isDistributed,
1444
- dataLabels: {
1445
- position: "top"
1446
- }
1447
- }
1448
- },
1449
- dataLabels: {
1450
- enabled: true,
1451
- formatter: function formatter(val) {
1452
- return "$".concat(formatNumber(val));
1453
- },
1454
- offsetY: exportMode ? -16 : -20,
1455
- style: {
1456
- fontSize: exportMode ? "7px" : "9px",
1457
- fontWeight: 600,
1458
- colors: ["#000"]
1459
- }
1460
- },
1461
- stroke: {
1462
- show: true,
1463
- width: 2,
1464
- colors: ["transparent"]
1465
- },
1466
- xaxis: {
1467
- categories: categories,
1468
- axisBorder: {
1469
- show: false
1470
- },
1471
- axisTicks: {
1472
- show: false
1473
- },
1474
- labels: {
1475
- style: {
1476
- colors: "rgba(0, 0, 0, 0.4)",
1477
- fontSize: exportMode ? "8px" : "11px"
1478
- }
1479
- }
1480
- },
1481
- yaxis: {
1482
- min: 0,
1483
- tickAmount: exportMode ? 3 : 4,
1484
- labels: {
1485
- formatter: function formatter(val) {
1486
- return "$".concat(formatNumber(val));
1487
- },
1488
- style: {
1489
- colors: "rgba(0, 0, 0, 0.4)",
1490
- fontSize: exportMode ? "8px" : "10px"
1491
- }
1492
- }
1493
- },
1494
- fill: {
1495
- opacity: 1
1496
- },
1497
- colors: colors,
1498
- grid: {
1499
- borderColor: "#f1f1f1",
1500
- strokeDashArray: 4,
1501
- padding: {
1502
- left: 0,
1503
- right: 0
1504
- },
1505
- yaxis: {
1506
- lines: {
1507
- show: true
1508
- }
1509
- }
1510
- },
1511
- legend: {
1512
- show: false
1513
- },
1514
- tooltip: {
1515
- y: {
1516
- formatter: function formatter(val) {
1517
- return "$".concat(formatNumber(val));
1518
- }
1519
- }
1520
- }
1521
- };
1522
- return /*#__PURE__*/jsxRuntime.jsxs(material.Card, {
1523
- sx: _objectSpread2({
1524
- bgcolor: "#fff",
1525
- borderRadius: exportMode ? 2 : 4,
1526
- border: exportMode ? "1px solid #DDE3EA" : "1px solid #f0f0f0",
1527
- boxShadow: exportMode ? "0 1px 0 rgba(15,23,42,0.03)" : "0 4px 24px rgba(0,0,0,0.06)",
1528
- p: exportMode ? 1.5 : 3,
1529
- height: exportMode ? "100%" : "auto",
1530
- boxSizing: "border-box"
1531
- }, sx),
1532
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1533
- sx: {
1534
- display: "flex",
1535
- flexDirection: "column"
1536
- },
1537
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1538
- sx: {
1539
- textAlign: "left"
1540
- },
1541
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1542
- sx: {
1543
- fontWeight: 700,
1544
- fontSize: exportMode ? "12px" : "18px",
1545
- color: "#000",
1546
- lineHeight: 1.15
1547
- },
1548
- children: title
1549
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1550
- sx: {
1551
- fontSize: exportMode ? "9.5px" : "13px",
1552
- color: exportMode ? "#94A3B8" : "rgba(0, 0, 0, 0.4)",
1553
- lineHeight: 1.15
1554
- },
1555
- children: subtitle
1556
- })]
1557
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1558
- sx: {
1559
- display: "flex",
1560
- gap: exportMode ? 1 : 1.5,
1561
- mt: exportMode ? 0.75 : 0.5,
1562
- flexWrap: "wrap"
1563
- },
1564
- children: summaries.map(function (item, index) {
1565
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1566
- sx: {
1567
- display: "flex",
1568
- alignItems: "center",
1569
- gap: 0.5
1570
- },
1571
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
1572
- sx: {
1573
- width: exportMode ? 6 : 8,
1574
- height: exportMode ? 6 : 8,
1575
- bgcolor: item.color,
1576
- borderRadius: "50%"
1577
- }
1578
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1579
- sx: {
1580
- fontSize: exportMode ? "9.5px" : "13px",
1581
- color: exportMode ? "#374151" : "rgba(0, 0, 0, 0.5)",
1582
- fontWeight: 500
1583
- },
1584
- children: item.label
1585
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
1586
- sx: {
1587
- fontSize: exportMode ? "9.5px" : "13px",
1588
- fontWeight: exportMode ? 700 : 600,
1589
- color: "#000"
1590
- },
1591
- children: ["$", formatNumber(item.total || 0)]
1592
- })]
1593
- }, item.label || index);
1594
- })
1595
- })]
1596
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1597
- sx: {
1598
- height: resolvedChartHeight,
1599
- width: exportMode ? "calc(100% + 24px)" : "calc(100% + 48px)",
1600
- ml: exportMode ? -1.5 : -3,
1601
- mr: exportMode ? -1.5 : -3
1602
- },
1603
- children: /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
1604
- options: chartOptions,
1605
- series: series,
1606
- type: "bar",
1607
- height: "100%"
1608
- })
1609
- })]
1610
- });
1611
- };
1612
-
1613
1332
  var PURPLE = "#6363E6";
1614
1333
  var REPORT_COLORS = {
1615
1334
  purple: PURPLE};
@@ -1680,6 +1399,57 @@ var parseDonationTypeTotals = function parseDonationTypeTotals(donationTypeData)
1680
1399
  };
1681
1400
  };
1682
1401
 
1402
+ /** Weekly chart points + totals for recurring vs one-time (PDF + report). */
1403
+ var parseDonationTypeChartData = function parseDonationTypeChartData(donationTypeData) {
1404
+ var empty = {
1405
+ categories: [],
1406
+ recurring: [],
1407
+ oneTime: [],
1408
+ recurringTotal: 0,
1409
+ oneTimeTotal: 0
1410
+ };
1411
+ if (donationTypeData !== null && donationTypeData !== void 0 && donationTypeData.data && Array.isArray(donationTypeData.data)) {
1412
+ var _donationTypeData$tot3, _donationTypeData$tot4;
1413
+ return {
1414
+ categories: donationTypeData.data.map(function (item) {
1415
+ return item.label || "";
1416
+ }),
1417
+ recurring: donationTypeData.data.map(function (item) {
1418
+ return Number(item.recurring || 0);
1419
+ }),
1420
+ oneTime: donationTypeData.data.map(function (item) {
1421
+ return Number(item.oneTime || 0);
1422
+ }),
1423
+ recurringTotal: Number((_donationTypeData$tot3 = donationTypeData.totalRecurringDonations) !== null && _donationTypeData$tot3 !== void 0 ? _donationTypeData$tot3 : 0),
1424
+ oneTimeTotal: Number((_donationTypeData$tot4 = donationTypeData.totalOneTimeDonations) !== null && _donationTypeData$tot4 !== void 0 ? _donationTypeData$tot4 : 0)
1425
+ };
1426
+ }
1427
+ if (Array.isArray(donationTypeData) && donationTypeData.length > 0 && donationTypeData[0].totalAmount !== undefined) {
1428
+ var totals = parseDonationTypeTotals(donationTypeData);
1429
+ return _objectSpread2(_objectSpread2({}, empty), totals);
1430
+ }
1431
+ if (Array.isArray(donationTypeData) && donationTypeData.length > 0 && (donationTypeData[0].recurring !== undefined || donationTypeData[0].oneTime !== undefined || donationTypeData[0].recurringAmount !== undefined || donationTypeData[0].oneTimeAmount !== undefined)) {
1432
+ return {
1433
+ categories: donationTypeData.map(function (item) {
1434
+ return item.label || item.date || "";
1435
+ }),
1436
+ recurring: donationTypeData.map(function (item) {
1437
+ return Number(item.recurring || item.recurringAmount || 0);
1438
+ }),
1439
+ oneTime: donationTypeData.map(function (item) {
1440
+ return Number(item.oneTime || item.oneTimeAmount || 0);
1441
+ }),
1442
+ recurringTotal: donationTypeData.reduce(function (sum, item) {
1443
+ return sum + Number(item.recurring || item.recurringAmount || 0);
1444
+ }, 0),
1445
+ oneTimeTotal: donationTypeData.reduce(function (sum, item) {
1446
+ return sum + Number(item.oneTime || item.oneTimeAmount || 0);
1447
+ }, 0)
1448
+ };
1449
+ }
1450
+ return _objectSpread2(_objectSpread2({}, empty), parseDonationTypeTotals(donationTypeData));
1451
+ };
1452
+
1683
1453
  /** Mirrors PaidDonorGeographyCard row mapping from donorGeography. */
1684
1454
  var parseDonorGeographyList = function parseDonorGeographyList(donorGeographyData) {
1685
1455
  var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.data) || [];
@@ -1945,6 +1715,12 @@ var kpiPct = function kpiPct(v) {
1945
1715
  var kpiRoas = function kpiRoas(v) {
1946
1716
  return "".concat(formatNumber(Number(v !== null && v !== void 0 ? v : 0).toFixed(2)), "\xD7");
1947
1717
  };
1718
+ var d$Compact = function d$Compact(v) {
1719
+ var n = Number(v !== null && v !== void 0 ? v : 0);
1720
+ if (n >= 1000000) return "$".concat((n / 1000000).toFixed(1), "M");
1721
+ if (n >= 1000) return "$".concat((n / 1000).toFixed(1), "K");
1722
+ return d$(n);
1723
+ };
1948
1724
  var pct = function pct(v) {
1949
1725
  var dp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
1950
1726
  return "".concat(Number(v !== null && v !== void 0 ? v : 0).toFixed(dp), "%");
@@ -2326,15 +2102,216 @@ var ProgressBar = function ProgressBar(_ref8) {
2326
2102
  })]
2327
2103
  });
2328
2104
  };
2329
- var KpiCard = function KpiCard(_ref9) {
2330
- var title = _ref9.title,
2331
- value = _ref9.value,
2332
- trend = _ref9.trend,
2333
- detail = _ref9.detail,
2334
- _ref9$variant = _ref9.variant,
2335
- variant = _ref9$variant === void 0 ? "secondary" : _ref9$variant,
2336
- _ref9$trendPositiveWh = _ref9.trendPositiveWhenNegative,
2337
- trendPositiveWhenNegative = _ref9$trendPositiveWh === void 0 ? false : _ref9$trendPositiveWh;
2105
+ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref9) {
2106
+ var _ref9$categories = _ref9.categories,
2107
+ categories = _ref9$categories === void 0 ? [] : _ref9$categories,
2108
+ _ref9$recurring = _ref9.recurring,
2109
+ recurring = _ref9$recurring === void 0 ? [] : _ref9$recurring,
2110
+ _ref9$oneTime = _ref9.oneTime,
2111
+ oneTime = _ref9$oneTime === void 0 ? [] : _ref9$oneTime,
2112
+ _ref9$recurringColor = _ref9.recurringColor,
2113
+ recurringColor = _ref9$recurringColor === void 0 ? "#6366F1" : _ref9$recurringColor,
2114
+ _ref9$oneTimeColor = _ref9.oneTimeColor,
2115
+ oneTimeColor = _ref9$oneTimeColor === void 0 ? "#10B981" : _ref9$oneTimeColor;
2116
+ var width = 158;
2117
+ var height = 96;
2118
+ var padL = 30;
2119
+ var padR = 2;
2120
+ var padT = 14;
2121
+ var padB = 18;
2122
+ var chartW = width - padL - padR;
2123
+ var chartH = height - padT - padB;
2124
+ var allVals = [].concat(_toConsumableArray(recurring), _toConsumableArray(oneTime));
2125
+ var maxVal = Math.max.apply(Math, _toConsumableArray(allVals).concat([0])) || 1;
2126
+ var n = categories.length;
2127
+ var yTicks = [0, maxVal / 2, maxVal];
2128
+ if (!n) {
2129
+ return /*#__PURE__*/jsxRuntime.jsxs("svg", {
2130
+ width: "100%",
2131
+ height: height,
2132
+ viewBox: "0 0 ".concat(width, " ").concat(height),
2133
+ style: {
2134
+ display: "block"
2135
+ },
2136
+ children: [/*#__PURE__*/jsxRuntime.jsx("line", {
2137
+ x1: padL,
2138
+ y1: padT + chartH,
2139
+ x2: width - padR,
2140
+ y2: padT + chartH,
2141
+ stroke: "#f1f1f1"
2142
+ }), /*#__PURE__*/jsxRuntime.jsx("text", {
2143
+ x: padL - 4,
2144
+ y: padT + chartH + 3,
2145
+ textAnchor: "end",
2146
+ fontSize: 7,
2147
+ fill: "rgba(0,0,0,0.4)",
2148
+ children: "$0"
2149
+ })]
2150
+ });
2151
+ }
2152
+ var groupW = chartW / n;
2153
+ var barW = Math.min(groupW * 0.3, 12);
2154
+ var baseY = padT + chartH;
2155
+ return /*#__PURE__*/jsxRuntime.jsxs("svg", {
2156
+ width: "100%",
2157
+ height: height,
2158
+ viewBox: "0 0 ".concat(width, " ").concat(height),
2159
+ style: {
2160
+ display: "block"
2161
+ },
2162
+ children: [yTicks.map(function (tick, i) {
2163
+ var y = padT + chartH - tick / maxVal * chartH;
2164
+ return /*#__PURE__*/jsxRuntime.jsxs("g", {
2165
+ children: [/*#__PURE__*/jsxRuntime.jsx("line", {
2166
+ x1: padL,
2167
+ y1: y,
2168
+ x2: width - padR,
2169
+ y2: y,
2170
+ stroke: "#f1f1f1",
2171
+ strokeDasharray: "4"
2172
+ }), /*#__PURE__*/jsxRuntime.jsx("text", {
2173
+ x: padL - 4,
2174
+ y: y + 3,
2175
+ textAnchor: "end",
2176
+ fontSize: 7,
2177
+ fill: "rgba(0,0,0,0.4)",
2178
+ children: d$Compact(tick)
2179
+ })]
2180
+ }, "y-".concat(i));
2181
+ }), categories.map(function (cat, i) {
2182
+ var groupX = padL + i * groupW + groupW / 2;
2183
+ var rVal = recurring[i] || 0;
2184
+ var oVal = oneTime[i] || 0;
2185
+ var rH = rVal / maxVal * chartH;
2186
+ var oH = oVal / maxVal * chartH;
2187
+ var rX = groupX - barW - 1;
2188
+ var oX = groupX + 1;
2189
+ return /*#__PURE__*/jsxRuntime.jsxs("g", {
2190
+ children: [rVal > 0 && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2191
+ children: [/*#__PURE__*/jsxRuntime.jsx("rect", {
2192
+ x: rX,
2193
+ y: baseY - rH,
2194
+ width: barW,
2195
+ height: Math.max(rH, 1),
2196
+ fill: recurringColor,
2197
+ rx: 2
2198
+ }), /*#__PURE__*/jsxRuntime.jsx("text", {
2199
+ x: rX + barW / 2,
2200
+ y: baseY - rH - 3,
2201
+ textAnchor: "middle",
2202
+ fontSize: 6.5,
2203
+ fontWeight: 600,
2204
+ fill: "#111827",
2205
+ children: d$Compact(rVal)
2206
+ })]
2207
+ }), oVal > 0 && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2208
+ children: [/*#__PURE__*/jsxRuntime.jsx("rect", {
2209
+ x: oX,
2210
+ y: baseY - oH,
2211
+ width: barW,
2212
+ height: Math.max(oH, 1),
2213
+ fill: oneTimeColor,
2214
+ rx: 2
2215
+ }), /*#__PURE__*/jsxRuntime.jsx("text", {
2216
+ x: oX + barW / 2,
2217
+ y: baseY - oH - 3,
2218
+ textAnchor: "middle",
2219
+ fontSize: 6.5,
2220
+ fontWeight: 600,
2221
+ fill: "#111827",
2222
+ children: d$Compact(oVal)
2223
+ })]
2224
+ }), /*#__PURE__*/jsxRuntime.jsx("text", {
2225
+ x: groupX,
2226
+ y: height - 4,
2227
+ textAnchor: "middle",
2228
+ fontSize: 7.5,
2229
+ fill: "rgba(0,0,0,0.4)",
2230
+ children: cat
2231
+ })]
2232
+ }, "bar-".concat(i));
2233
+ })]
2234
+ });
2235
+ };
2236
+ var DonationTypePanel = function DonationTypePanel(_ref0) {
2237
+ var donationTypeData = _ref0.donationTypeData,
2238
+ _ref0$recurringColor = _ref0.recurringColor,
2239
+ recurringColor = _ref0$recurringColor === void 0 ? "#6366F1" : _ref0$recurringColor,
2240
+ _ref0$oneTimeColor = _ref0.oneTimeColor,
2241
+ oneTimeColor = _ref0$oneTimeColor === void 0 ? "#10B981" : _ref0$oneTimeColor;
2242
+ var _parseDonationTypeCha = parseDonationTypeChartData(donationTypeData),
2243
+ categories = _parseDonationTypeCha.categories,
2244
+ recurring = _parseDonationTypeCha.recurring,
2245
+ oneTime = _parseDonationTypeCha.oneTime,
2246
+ recurringTotal = _parseDonationTypeCha.recurringTotal,
2247
+ oneTimeTotal = _parseDonationTypeCha.oneTimeTotal;
2248
+ return /*#__PURE__*/jsxRuntime.jsxs(Panel, {
2249
+ title: "Recurring vs one-time",
2250
+ subtitle: "Donation type \xB7 weekly",
2251
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
2252
+ style: {
2253
+ display: "flex",
2254
+ flexWrap: "wrap",
2255
+ gap: "6px 10px",
2256
+ marginBottom: 4
2257
+ },
2258
+ children: [{
2259
+ label: "Recurring",
2260
+ total: recurringTotal,
2261
+ color: recurringColor
2262
+ }, {
2263
+ label: "One-time",
2264
+ total: oneTimeTotal,
2265
+ color: oneTimeColor
2266
+ }].map(function (item) {
2267
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
2268
+ style: {
2269
+ display: "flex",
2270
+ alignItems: "center",
2271
+ gap: 4
2272
+ },
2273
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
2274
+ style: {
2275
+ width: 6,
2276
+ height: 6,
2277
+ borderRadius: "50%",
2278
+ background: item.color,
2279
+ flexShrink: 0
2280
+ }
2281
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
2282
+ style: {
2283
+ fontSize: 9.5,
2284
+ color: "#374151"
2285
+ },
2286
+ children: item.label
2287
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
2288
+ style: {
2289
+ fontSize: 9.5,
2290
+ fontWeight: 700,
2291
+ color: "#111827"
2292
+ },
2293
+ children: d$(item.total)
2294
+ })]
2295
+ }, item.label);
2296
+ })
2297
+ }), /*#__PURE__*/jsxRuntime.jsx(DonationTypeBarSvg, {
2298
+ categories: categories,
2299
+ recurring: recurring,
2300
+ oneTime: oneTime,
2301
+ recurringColor: recurringColor,
2302
+ oneTimeColor: oneTimeColor
2303
+ })]
2304
+ });
2305
+ };
2306
+ var KpiCard = function KpiCard(_ref1) {
2307
+ var title = _ref1.title,
2308
+ value = _ref1.value,
2309
+ trend = _ref1.trend,
2310
+ detail = _ref1.detail,
2311
+ _ref1$variant = _ref1.variant,
2312
+ variant = _ref1$variant === void 0 ? "secondary" : _ref1$variant,
2313
+ _ref1$trendPositiveWh = _ref1.trendPositiveWhenNegative,
2314
+ trendPositiveWhenNegative = _ref1$trendPositiveWh === void 0 ? false : _ref1$trendPositiveWh;
2338
2315
  var displayTrend = withTrendArrow(trend);
2339
2316
  var isPrimary = variant === "primary";
2340
2317
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -2385,10 +2362,10 @@ var KpiCard = function KpiCard(_ref9) {
2385
2362
  })]
2386
2363
  });
2387
2364
  };
2388
- var StatPair = function StatPair(_ref0) {
2389
- var label = _ref0.label,
2390
- val = _ref0.val,
2391
- trend = _ref0.trend;
2365
+ var StatPair = function StatPair(_ref10) {
2366
+ var label = _ref10.label,
2367
+ val = _ref10.val,
2368
+ trend = _ref10.trend;
2392
2369
  var displayTrend = withTrendArrow(trend);
2393
2370
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2394
2371
  style: {
@@ -2425,12 +2402,12 @@ var StatPair = function StatPair(_ref0) {
2425
2402
  })]
2426
2403
  });
2427
2404
  };
2428
- var PageHeader = function PageHeader(_ref1) {
2429
- var dateLabel = _ref1.dateLabel,
2430
- generatedLabel = _ref1.generatedLabel,
2431
- activeFilters = _ref1.activeFilters,
2432
- page = _ref1.page,
2433
- windowLabel = _ref1.windowLabel;
2405
+ var PageHeader = function PageHeader(_ref11) {
2406
+ var dateLabel = _ref11.dateLabel,
2407
+ generatedLabel = _ref11.generatedLabel,
2408
+ activeFilters = _ref11.activeFilters,
2409
+ page = _ref11.page,
2410
+ windowLabel = _ref11.windowLabel;
2434
2411
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2435
2412
  style: {
2436
2413
  padding: "22px ".concat(MX, "px 12px"),
@@ -2536,9 +2513,9 @@ var PageHeader = function PageHeader(_ref1) {
2536
2513
  })]
2537
2514
  });
2538
2515
  };
2539
- var PageFooter = function PageFooter(_ref10) {
2540
- var generatedLabel = _ref10.generatedLabel,
2541
- page = _ref10.page;
2516
+ var PageFooter = function PageFooter(_ref12) {
2517
+ var generatedLabel = _ref12.generatedLabel,
2518
+ page = _ref12.page;
2542
2519
  return /*#__PURE__*/jsxRuntime.jsx("div", {
2543
2520
  style: {
2544
2521
  padding: "7px ".concat(MX, "px"),
@@ -2558,16 +2535,16 @@ var PageFooter = function PageFooter(_ref10) {
2558
2535
  };
2559
2536
 
2560
2537
  // ─── Main component ───────────────────────────────────────────────────────────
2561
- var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2562
- var _apiData$overviewStat, _overview$totalRevenu, _overview$netRevenue, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _refundsRaw$refundRat, _refundsRaw$chargebac, _apiData$trafficSourc2, _metricByTitle$NetRa, _metricByTitle$Total, _metricByTitle$Total2, _metricByTitle$Total3, _metricByTitle$AvgDo, _metricByTitle$AvgDo2, _apiData$medianGift, _apiData$topDecileGif, _apiData$roasCard, _metricByTitle$ROAS, _apiData$roasCardPrev, _metricByTitle$ROAS2, _apiData$adSpend, _apiData$attributedRe, _metricByTitle$Conver, _metricByTitle$Conver2, _metricByTitle$Refund, _metricByTitle$Refund2, _refundsRaw$refundCou, _metricByTitle$Refund3, _mainChart$stacked, _ref14, _refundsRaw$refundRat2, _ob$growthPercentage, _ob$peakDay, _refCard$growthPercen;
2563
- var _ref11$apiData = _ref11.apiData,
2564
- apiData = _ref11$apiData === void 0 ? {} : _ref11$apiData,
2565
- _ref11$dateName = _ref11.dateName,
2566
- dateName = _ref11$dateName === void 0 ? "Last Period" : _ref11$dateName,
2567
- _ref11$numberOfDays = _ref11.numberOfDays,
2568
- numberOfDays = _ref11$numberOfDays === void 0 ? 30 : _ref11$numberOfDays,
2569
- _ref11$activeFilters = _ref11.activeFilters,
2570
- activeFilters = _ref11$activeFilters === void 0 ? [] : _ref11$activeFilters;
2538
+ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref13, ref) {
2539
+ var _apiData$overviewStat, _overview$totalRevenu, _overview$netRevenue, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _refundsRaw$refundRat, _refundsRaw$chargebac, _apiData$trafficSourc2, _metricByTitle$NetRa, _metricByTitle$Total, _metricByTitle$Total2, _metricByTitle$Total3, _metricByTitle$AvgDo, _metricByTitle$AvgDo2, _apiData$medianGift, _apiData$topDecileGif, _apiData$roasCard, _metricByTitle$ROAS, _apiData$roasCardPrev, _metricByTitle$ROAS2, _apiData$adSpend, _apiData$attributedRe, _metricByTitle$Conver, _metricByTitle$Conver2, _metricByTitle$Refund, _metricByTitle$Refund2, _refundsRaw$refundCou, _metricByTitle$Refund3, _mainChart$stacked, _ref16, _refundsRaw$refundRat2, _ob$growthPercentage, _ob$peakDay, _refCard$growthPercen;
2540
+ var _ref13$apiData = _ref13.apiData,
2541
+ apiData = _ref13$apiData === void 0 ? {} : _ref13$apiData,
2542
+ _ref13$dateName = _ref13.dateName,
2543
+ dateName = _ref13$dateName === void 0 ? "Last Period" : _ref13$dateName,
2544
+ _ref13$numberOfDays = _ref13.numberOfDays,
2545
+ numberOfDays = _ref13$numberOfDays === void 0 ? 30 : _ref13$numberOfDays,
2546
+ _ref13$activeFilters = _ref13.activeFilters,
2547
+ activeFilters = _ref13$activeFilters === void 0 ? [] : _ref13$activeFilters;
2571
2548
  var now = new Date();
2572
2549
  var daysLabel = "".concat(numberOfDays, " day").concat(numberOfDays === 1 ? "" : "s");
2573
2550
  var windowLabel = "".concat(numberOfDays, "-day window");
@@ -2675,7 +2652,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2675
2652
  data: []
2676
2653
  }];
2677
2654
  var revCats = mainChart.categories || [];
2678
- var campaigns = ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).length ? apiData.activeCampaigns : [{
2655
+ ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).length ? apiData.activeCampaigns : [{
2679
2656
  title: "Orphan sponsorship — Yemen",
2680
2657
  collectedAmount: 78400,
2681
2658
  usdTargetAmount: 100000,
@@ -2711,9 +2688,6 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2711
2688
  averageDonation: 1940,
2712
2689
  status: "Active"
2713
2690
  }];
2714
- var campaignStatusByIndex = campaigns.map(function (c) {
2715
- return c.status || "Active";
2716
- });
2717
2691
  var ob = (apiData === null || apiData === void 0 ? void 0 : apiData.orderBumpDetails) || {};
2718
2692
  var obData = ((ob === null || ob === void 0 ? void 0 : ob.chart) || []).map(function (i) {
2719
2693
  return Number(i.revenue || 0);
@@ -2876,10 +2850,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2876
2850
  gap: 14,
2877
2851
  marginBottom: 6
2878
2852
  },
2879
- children: [["Email", C.cyan], ["Organic", C.emerald], ["Paid Ads", C.indigo]].map(function (_ref12) {
2880
- var _ref13 = _slicedToArray(_ref12, 2),
2881
- name = _ref13[0],
2882
- color = _ref13[1];
2853
+ children: [["Email", C.cyan], ["Organic", C.emerald], ["Paid Ads", C.indigo]].map(function (_ref14) {
2854
+ var _ref15 = _slicedToArray(_ref14, 2),
2855
+ name = _ref15[0],
2856
+ color = _ref15[1];
2883
2857
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2884
2858
  style: {
2885
2859
  display: "flex",
@@ -2955,12 +2929,12 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2955
2929
  title: "Active campaigns",
2956
2930
  subtitle: "Live fundraisers ranked by velocity",
2957
2931
  children: /*#__PURE__*/jsxRuntime.jsx(MiniTable, {
2958
- head: ["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT", "STATUS"],
2959
- colAlign: ["left", "right", "left", "right", "right", "right"],
2932
+ head: ["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT"],
2933
+ colAlign: ["left", "right", "left", "right", "right"],
2960
2934
  rows: activeCampaigns.map(function (c, i) {
2961
2935
  return [c.name, c.val1, /*#__PURE__*/jsxRuntime.jsx(ProgressBar, {
2962
2936
  value: c.progress
2963
- }, "campaign-progress-".concat(i)), c.val3, c.val4, campaignStatusByIndex[i] || "Active"];
2937
+ }, "campaign-progress-".concat(i)), c.val3, c.val4];
2964
2938
  })
2965
2939
  })
2966
2940
  }), /*#__PURE__*/jsxRuntime.jsx(Panel, {
@@ -3055,7 +3029,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3055
3029
  style: {
3056
3030
  fontSize: 9
3057
3031
  },
3058
- children: "".concat(Number((_ref14 = donorMixPrev !== null && donorMixPrev !== void 0 ? donorMixPrev : growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _ref14 !== void 0 ? _ref14 : 0).toFixed(2), "% vs pp")
3032
+ children: "".concat(Number((_ref16 = donorMixPrev !== null && donorMixPrev !== void 0 ? donorMixPrev : growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _ref16 !== void 0 ? _ref16 : 0).toFixed(2), "% vs pp")
3059
3033
  })
3060
3034
  })]
3061
3035
  })]
@@ -3067,10 +3041,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3067
3041
  gridTemplateColumns: "repeat(4, 1fr)",
3068
3042
  gap: 8
3069
3043
  },
3070
- children: [/*#__PURE__*/jsxRuntime.jsx(DonationTypeBarChart, {
3071
- exportMode: true,
3072
- subtitle: "Donation type \xB7 weekly",
3073
- donationTypeData: report.donationTypeData
3044
+ children: [/*#__PURE__*/jsxRuntime.jsx(DonationTypePanel, {
3045
+ donationTypeData: report.donationTypeData,
3046
+ recurringColor: C.indigo,
3047
+ oneTimeColor: C.emerald
3074
3048
  }), /*#__PURE__*/jsxRuntime.jsx(Panel, {
3075
3049
  title: "Donor geography",
3076
3050
  subtitle: "Top countries \xB7 ".concat(formatNumber(totalDonors), " total"),
@@ -3226,10 +3200,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3226
3200
  display: "flex",
3227
3201
  gap: 12
3228
3202
  },
3229
- children: [["Avg/day", d$((ob === null || ob === void 0 ? void 0 : ob.averagePerDay) || 0)], ["Peak day", d$((ob === null || ob === void 0 || (_ob$peakDay = ob.peakDay) === null || _ob$peakDay === void 0 ? void 0 : _ob$peakDay.amount) || 0)], ["Orders", formatNumber((ob === null || ob === void 0 ? void 0 : ob.totalOrders) || 0)]].map(function (_ref15) {
3230
- var _ref16 = _slicedToArray(_ref15, 2),
3231
- l = _ref16[0],
3232
- v = _ref16[1];
3203
+ children: [["Avg/day", d$((ob === null || ob === void 0 ? void 0 : ob.averagePerDay) || 0)], ["Peak day", d$((ob === null || ob === void 0 || (_ob$peakDay = ob.peakDay) === null || _ob$peakDay === void 0 ? void 0 : _ob$peakDay.amount) || 0)], ["Orders", formatNumber((ob === null || ob === void 0 ? void 0 : ob.totalOrders) || 0)]].map(function (_ref17) {
3204
+ var _ref18 = _slicedToArray(_ref17, 2),
3205
+ l = _ref18[0],
3206
+ v = _ref18[1];
3233
3207
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3234
3208
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3235
3209
  style: {
@@ -3356,10 +3330,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3356
3330
  display: "flex",
3357
3331
  gap: 12
3358
3332
  },
3359
- children: [["Referrers", formatNumber((refCard === null || refCard === void 0 ? void 0 : refCard.totalReferrers) || 0)], ["Avg gift", d$((refCard === null || refCard === void 0 ? void 0 : refCard.averageGift) || 0)], ["Conv. rate", pct((refCard === null || refCard === void 0 ? void 0 : refCard.conversionRate) || 0, 1)]].map(function (_ref17) {
3360
- var _ref18 = _slicedToArray(_ref17, 2),
3361
- l = _ref18[0],
3362
- v = _ref18[1];
3333
+ children: [["Referrers", formatNumber((refCard === null || refCard === void 0 ? void 0 : refCard.totalReferrers) || 0)], ["Avg gift", d$((refCard === null || refCard === void 0 ? void 0 : refCard.averageGift) || 0)], ["Conv. rate", pct((refCard === null || refCard === void 0 ? void 0 : refCard.conversionRate) || 0, 1)]].map(function (_ref19) {
3334
+ var _ref20 = _slicedToArray(_ref19, 2),
3335
+ l = _ref20[0],
3336
+ v = _ref20[1];
3363
3337
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3364
3338
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3365
3339
  style: {
@@ -4703,274 +4677,555 @@ var MetricSparklineCard = function MetricSparklineCard(_ref) {
4703
4677
  sx: {
4704
4678
  display: "flex",
4705
4679
  justifyContent: "space-between",
4706
- mt: 0.5
4680
+ mt: 0.5
4681
+ },
4682
+ children: axisLabels.map(function (label, idx) {
4683
+ return /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4684
+ sx: {
4685
+ fontSize: "10px",
4686
+ color: "rgba(0, 0, 0, 0.3)"
4687
+ },
4688
+ children: label
4689
+ }, "".concat(label, "-").concat(idx));
4690
+ })
4691
+ })]
4692
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4693
+ sx: {
4694
+ mt: "auto",
4695
+ pt: bottomSection ? 1.5 : 3,
4696
+ display: "flex",
4697
+ justifyContent: "space-between"
4698
+ },
4699
+ children: footerMetrics.map(function (m, idx) {
4700
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4701
+ sx: {
4702
+ textAlign: "center"
4703
+ },
4704
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4705
+ sx: {
4706
+ fontSize: "10px",
4707
+ color: "rgba(0, 0, 0, 0.4)",
4708
+ fontWeight: 500
4709
+ },
4710
+ children: m.label
4711
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4712
+ sx: {
4713
+ fontSize: "14px",
4714
+ fontWeight: 700,
4715
+ color: "#000"
4716
+ },
4717
+ children: "".concat(formatNumber(m.value))
4718
+ })]
4719
+ }, idx);
4720
+ })
4721
+ })]
4722
+ });
4723
+ };
4724
+
4725
+ var TrendValue = function TrendValue(_ref) {
4726
+ var trend = _ref.trend;
4727
+ var direction = getTrendDirection(trend);
4728
+ var color = getTrendColor(trend);
4729
+ var Icon = direction === "down" ? iconsMaterial.TrendingDown : iconsMaterial.TrendingUp;
4730
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
4731
+ sx: {
4732
+ fontSize: "10px",
4733
+ fontWeight: 700,
4734
+ color: color,
4735
+ display: "flex",
4736
+ alignItems: "center"
4737
+ },
4738
+ children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {
4739
+ sx: {
4740
+ fontSize: "12px"
4741
+ }
4742
+ }), " ", trend]
4743
+ });
4744
+ };
4745
+ var MetricDonutCard = function MetricDonutCard(_ref2) {
4746
+ var title = _ref2.title,
4747
+ subtitle = _ref2.subtitle,
4748
+ acceptanceRate = _ref2.acceptanceRate,
4749
+ acceptanceVal = _ref2.acceptanceVal,
4750
+ acceptanceTrend = _ref2.acceptanceTrend,
4751
+ raisedVal = _ref2.raisedVal,
4752
+ raisedTrend = _ref2.raisedTrend,
4753
+ _ref2$chartColors = _ref2.chartColors,
4754
+ chartColors = _ref2$chartColors === void 0 ? ["rgb(99, 99, 230)", "#88bfd290"] : _ref2$chartColors,
4755
+ sx = _ref2.sx,
4756
+ _ref2$compact = _ref2.compact,
4757
+ compact = _ref2$compact === void 0 ? false : _ref2$compact;
4758
+ var chartOptions = {
4759
+ chart: {
4760
+ type: "radialBar",
4761
+ sparkline: {
4762
+ enabled: true
4763
+ }
4764
+ },
4765
+ plotOptions: {
4766
+ radialBar: {
4767
+ hollow: {
4768
+ size: "45%"
4769
+ },
4770
+ track: {
4771
+ background: chartColors[1] || "#f0f0f0",
4772
+ strokeWidth: "100%"
4773
+ },
4774
+ dataLabels: {
4775
+ name: {
4776
+ show: true,
4777
+ fontSize: "11px",
4778
+ fontWeight: 500,
4779
+ color: "rgba(0, 0, 0, 0.4)",
4780
+ offsetY: 15
4781
+ },
4782
+ value: {
4783
+ show: true,
4784
+ fontSize: "18px",
4785
+ fontWeight: 700,
4786
+ color: "#000",
4787
+ offsetY: -15,
4788
+ formatter: function formatter() {
4789
+ return acceptanceRate + "%";
4790
+ }
4791
+ }
4792
+ }
4793
+ }
4794
+ },
4795
+ stroke: {
4796
+ lineCap: "butt"
4797
+ },
4798
+ colors: [chartColors[0]],
4799
+ labels: ["accepted"],
4800
+ tooltip: {
4801
+ enabled: true,
4802
+ theme: "dark",
4803
+ y: {
4804
+ formatter: function formatter(val) {
4805
+ return "".concat(val, "%");
4806
+ }
4807
+ }
4808
+ }
4809
+ };
4810
+ var series = [acceptanceRate];
4811
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Card, {
4812
+ sx: _objectSpread2({
4813
+ p: compact ? 1.25 : 3,
4814
+ borderRadius: compact ? 3 : 4,
4815
+ border: "1px solid #f0f0f0",
4816
+ boxShadow: "0 4px 24px rgba(0,0,0,0.06)",
4817
+ bgcolor: "#fff",
4818
+ // height: "100%",
4819
+ display: "flex",
4820
+ flexDirection: "column"
4821
+ }, sx),
4822
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4823
+ sx: {},
4824
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4825
+ sx: {
4826
+ fontWeight: 700,
4827
+ fontSize: compact ? "13px" : "16px",
4828
+ color: "#000",
4829
+ textAlign: "left",
4830
+ lineHeight: 1.15
4831
+ },
4832
+ children: title
4833
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4834
+ sx: {
4835
+ fontSize: "12px",
4836
+ color: "rgba(0, 0, 0, 0.4)",
4837
+ textAlign: "left",
4838
+ lineHeight: 1.15
4839
+ },
4840
+ children: subtitle
4841
+ })]
4842
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4843
+ sx: {
4844
+ height: compact ? 90 : 160,
4845
+ position: "relative",
4846
+ mt: compact ? 0.5 : 1,
4847
+ display: "flex",
4848
+ justifyContent: "center"
4849
+ },
4850
+ children: /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
4851
+ options: chartOptions,
4852
+ series: series,
4853
+ type: "radialBar",
4854
+ width: "100%",
4855
+ height: "100%"
4856
+ })
4857
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4858
+ sx: {},
4859
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4860
+ sx: {
4861
+ display: "flex",
4862
+ justifyContent: "space-between",
4863
+ alignItems: "center"
4864
+ },
4865
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4866
+ sx: {
4867
+ display: "flex",
4868
+ alignItems: "center",
4869
+ gap: 1
4870
+ },
4871
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
4872
+ sx: {
4873
+ width: 10,
4874
+ height: 10,
4875
+ bgcolor: chartColors[0],
4876
+ borderRadius: "2px"
4877
+ }
4878
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4879
+ sx: {
4880
+ fontSize: "13px",
4881
+ color: "rgba(0, 0, 0, 0.5)",
4882
+ fontWeight: 500
4883
+ },
4884
+ children: "Acceptance"
4885
+ })]
4886
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4887
+ sx: {
4888
+ display: "flex",
4889
+ alignItems: "center",
4890
+ gap: 0.5
4891
+ },
4892
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4893
+ sx: {
4894
+ fontSize: "13px",
4895
+ fontWeight: 700,
4896
+ color: "#000"
4897
+ },
4898
+ children: acceptanceVal
4899
+ }), /*#__PURE__*/jsxRuntime.jsx(TrendValue, {
4900
+ trend: acceptanceTrend
4901
+ })]
4902
+ })]
4903
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4904
+ sx: {
4905
+ display: "flex",
4906
+ justifyContent: "space-between",
4907
+ alignItems: "center"
4707
4908
  },
4708
- children: axisLabels.map(function (label, idx) {
4709
- return /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4710
- sx: {
4711
- fontSize: "10px",
4712
- color: "rgba(0, 0, 0, 0.3)"
4713
- },
4714
- children: label
4715
- }, "".concat(label, "-").concat(idx));
4716
- })
4717
- })]
4718
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4719
- sx: {
4720
- mt: "auto",
4721
- pt: bottomSection ? 1.5 : 3,
4722
- display: "flex",
4723
- justifyContent: "space-between"
4724
- },
4725
- children: footerMetrics.map(function (m, idx) {
4726
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4909
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4727
4910
  sx: {
4728
- textAlign: "center"
4911
+ display: "flex",
4912
+ alignItems: "center",
4913
+ gap: 1
4729
4914
  },
4730
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4915
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
4731
4916
  sx: {
4732
- fontSize: "10px",
4733
- color: "rgba(0, 0, 0, 0.4)",
4917
+ width: 10,
4918
+ height: 10,
4919
+ bgcolor: chartColors[1],
4920
+ borderRadius: "2px"
4921
+ }
4922
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4923
+ sx: {
4924
+ fontSize: "13px",
4925
+ color: "rgba(0, 0, 0, 0.5)",
4734
4926
  fontWeight: 500
4735
4927
  },
4736
- children: m.label
4737
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4928
+ children: "Raised"
4929
+ })]
4930
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4931
+ sx: {
4932
+ display: "flex",
4933
+ alignItems: "center",
4934
+ gap: 0.5
4935
+ },
4936
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4738
4937
  sx: {
4739
- fontSize: "14px",
4938
+ fontSize: "13px",
4740
4939
  fontWeight: 700,
4741
4940
  color: "#000"
4742
4941
  },
4743
- children: "".concat(formatNumber(m.value))
4942
+ children: raisedVal
4943
+ }), /*#__PURE__*/jsxRuntime.jsx(TrendValue, {
4944
+ trend: raisedTrend
4744
4945
  })]
4745
- }, idx);
4746
- })
4946
+ })]
4947
+ })]
4747
4948
  })]
4748
4949
  });
4749
4950
  };
4750
4951
 
4751
- var TrendValue = function TrendValue(_ref) {
4752
- var trend = _ref.trend;
4753
- var direction = getTrendDirection(trend);
4754
- var color = getTrendColor(trend);
4755
- var Icon = direction === "down" ? iconsMaterial.TrendingDown : iconsMaterial.TrendingUp;
4756
- return /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
4757
- sx: {
4758
- fontSize: "10px",
4759
- fontWeight: 700,
4760
- color: color,
4761
- display: "flex",
4762
- alignItems: "center"
4763
- },
4764
- children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {
4765
- sx: {
4766
- fontSize: "12px"
4767
- }
4768
- }), " ", trend]
4769
- });
4770
- };
4771
- var MetricDonutCard = function MetricDonutCard(_ref2) {
4772
- var title = _ref2.title,
4773
- subtitle = _ref2.subtitle,
4774
- acceptanceRate = _ref2.acceptanceRate,
4775
- acceptanceVal = _ref2.acceptanceVal,
4776
- acceptanceTrend = _ref2.acceptanceTrend,
4777
- raisedVal = _ref2.raisedVal,
4778
- raisedTrend = _ref2.raisedTrend,
4779
- _ref2$chartColors = _ref2.chartColors,
4780
- chartColors = _ref2$chartColors === void 0 ? ["rgb(99, 99, 230)", "#88bfd290"] : _ref2$chartColors,
4781
- sx = _ref2.sx,
4782
- _ref2$compact = _ref2.compact,
4783
- compact = _ref2$compact === void 0 ? false : _ref2$compact;
4952
+ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
4953
+ var sx = _ref.sx,
4954
+ donationTypeData = _ref.donationTypeData,
4955
+ _ref$exportMode = _ref.exportMode,
4956
+ exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode,
4957
+ _ref$subtitle = _ref.subtitle,
4958
+ subtitle = _ref$subtitle === void 0 ? "Donation type" : _ref$subtitle,
4959
+ chartHeight = _ref.chartHeight;
4960
+ var recurringColor = "rgb(99, 99, 230)";
4961
+ var oneTimeColor = "#10B981";
4962
+ var colors = [recurringColor, oneTimeColor, "#06B6D4", "#F59E0B", "#EF4444"];
4963
+ var categories = [];
4964
+ var series = [];
4965
+ var summaries = [];
4966
+ var title = "Donation Type";
4967
+ var isDistributed = false;
4968
+ if (donationTypeData && donationTypeData.data && Array.isArray(donationTypeData.data)) {
4969
+ // Time series recurring vs one-time format
4970
+ categories = donationTypeData.data.map(function (item) {
4971
+ return item.label || "";
4972
+ });
4973
+ series = [{
4974
+ name: "Recurring",
4975
+ data: donationTypeData.data.map(function (item) {
4976
+ return item.recurring || 0;
4977
+ })
4978
+ }, {
4979
+ name: "One-time",
4980
+ data: donationTypeData.data.map(function (item) {
4981
+ return item.oneTime || 0;
4982
+ })
4983
+ }];
4984
+ summaries = [{
4985
+ label: "Recurring",
4986
+ total: donationTypeData.totalRecurringDonations || 0,
4987
+ color: recurringColor
4988
+ }, {
4989
+ label: "One-time",
4990
+ total: donationTypeData.totalOneTimeDonations || 0,
4991
+ color: oneTimeColor
4992
+ }];
4993
+ title = "Recurring vs One-time";
4994
+ isDistributed = false;
4995
+ } else if (Array.isArray(donationTypeData) && donationTypeData.length > 0 && donationTypeData[0].totalAmount !== undefined) {
4996
+ // New array format
4997
+ categories = donationTypeData.map(function (item) {
4998
+ return item.type || "";
4999
+ });
5000
+ series = [{
5001
+ name: "Amount",
5002
+ data: donationTypeData.map(function (item) {
5003
+ return item.totalAmount || 0;
5004
+ })
5005
+ }];
5006
+ summaries = donationTypeData.map(function (item, index) {
5007
+ return {
5008
+ label: item.type || "",
5009
+ total: item.totalAmount || 0,
5010
+ color: colors[index % colors.length]
5011
+ };
5012
+ });
5013
+ isDistributed = true;
5014
+ if (donationTypeData.length === 2) {
5015
+ title = "".concat(donationTypeData[0].type, " vs ").concat(donationTypeData[1].type);
5016
+ }
5017
+ } else {
5018
+ var _dataObj$summary, _dataObj$summary2, _dataObj$summary3, _dataObj$summary4;
5019
+ // Object format, empty array, or missing data
5020
+ var dataObj = donationTypeData && _typeof(donationTypeData) === "object" && !Array.isArray(donationTypeData) ? donationTypeData : {};
5021
+ categories = dataObj.categories || [];
5022
+ var rawSeries = dataObj.series || [];
5023
+ if (rawSeries.length && categories.length) {
5024
+ series = rawSeries;
5025
+ } else {
5026
+ series = [{
5027
+ name: "Recurring",
5028
+ data: []
5029
+ }, {
5030
+ name: "One-time",
5031
+ data: []
5032
+ }];
5033
+ }
5034
+ summaries = [{
5035
+ 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",
5036
+ 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,
5037
+ color: recurringColor
5038
+ }, {
5039
+ 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",
5040
+ 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,
5041
+ color: oneTimeColor
5042
+ }];
5043
+ title = "Recurring vs one-time";
5044
+ isDistributed = false;
5045
+ }
5046
+ var resolvedChartHeight = chartHeight !== null && chartHeight !== void 0 ? chartHeight : exportMode ? 110 : 170;
4784
5047
  var chartOptions = {
4785
5048
  chart: {
4786
- type: "radialBar",
4787
- sparkline: {
4788
- enabled: true
5049
+ type: "bar",
5050
+ toolbar: {
5051
+ show: false
5052
+ },
5053
+ zoom: {
5054
+ enabled: false
5055
+ },
5056
+ fontFamily: "Inter, sans-serif"
5057
+ },
5058
+ plotOptions: {
5059
+ bar: {
5060
+ horizontal: false,
5061
+ columnWidth: exportMode ? "68%" : "75%",
5062
+ borderRadius: exportMode ? 3 : 4,
5063
+ distributed: isDistributed,
5064
+ dataLabels: {
5065
+ position: "top"
5066
+ }
5067
+ }
5068
+ },
5069
+ dataLabels: {
5070
+ enabled: true,
5071
+ formatter: function formatter(val) {
5072
+ return "$".concat(formatNumber(val));
5073
+ },
5074
+ offsetY: exportMode ? -16 : -20,
5075
+ style: {
5076
+ fontSize: exportMode ? "7px" : "9px",
5077
+ fontWeight: 600,
5078
+ colors: ["#000"]
5079
+ }
5080
+ },
5081
+ stroke: {
5082
+ show: true,
5083
+ width: 2,
5084
+ colors: ["transparent"]
5085
+ },
5086
+ xaxis: {
5087
+ categories: categories,
5088
+ axisBorder: {
5089
+ show: false
5090
+ },
5091
+ axisTicks: {
5092
+ show: false
5093
+ },
5094
+ labels: {
5095
+ style: {
5096
+ colors: "rgba(0, 0, 0, 0.4)",
5097
+ fontSize: exportMode ? "8px" : "11px"
5098
+ }
4789
5099
  }
4790
5100
  },
4791
- plotOptions: {
4792
- radialBar: {
4793
- hollow: {
4794
- size: "45%"
4795
- },
4796
- track: {
4797
- background: chartColors[1] || "#f0f0f0",
4798
- strokeWidth: "100%"
5101
+ yaxis: {
5102
+ min: 0,
5103
+ tickAmount: exportMode ? 3 : 4,
5104
+ labels: {
5105
+ formatter: function formatter(val) {
5106
+ return "$".concat(formatNumber(val));
4799
5107
  },
4800
- dataLabels: {
4801
- name: {
4802
- show: true,
4803
- fontSize: "11px",
4804
- fontWeight: 500,
4805
- color: "rgba(0, 0, 0, 0.4)",
4806
- offsetY: 15
4807
- },
4808
- value: {
4809
- show: true,
4810
- fontSize: "18px",
4811
- fontWeight: 700,
4812
- color: "#000",
4813
- offsetY: -15,
4814
- formatter: function formatter() {
4815
- return acceptanceRate + "%";
4816
- }
4817
- }
5108
+ style: {
5109
+ colors: "rgba(0, 0, 0, 0.4)",
5110
+ fontSize: exportMode ? "8px" : "10px"
4818
5111
  }
4819
5112
  }
4820
5113
  },
4821
- stroke: {
4822
- lineCap: "butt"
5114
+ fill: {
5115
+ opacity: 1
5116
+ },
5117
+ colors: colors,
5118
+ grid: {
5119
+ borderColor: "#f1f1f1",
5120
+ strokeDashArray: 4,
5121
+ padding: {
5122
+ left: 0,
5123
+ right: 0
5124
+ },
5125
+ yaxis: {
5126
+ lines: {
5127
+ show: true
5128
+ }
5129
+ }
5130
+ },
5131
+ legend: {
5132
+ show: false
4823
5133
  },
4824
- colors: [chartColors[0]],
4825
- labels: ["accepted"],
4826
5134
  tooltip: {
4827
- enabled: true,
4828
- theme: "dark",
4829
5135
  y: {
4830
5136
  formatter: function formatter(val) {
4831
- return "".concat(val, "%");
5137
+ return "$".concat(formatNumber(val));
4832
5138
  }
4833
5139
  }
4834
5140
  }
4835
5141
  };
4836
- var series = [acceptanceRate];
4837
5142
  return /*#__PURE__*/jsxRuntime.jsxs(material.Card, {
4838
5143
  sx: _objectSpread2({
4839
- p: compact ? 1.25 : 3,
4840
- borderRadius: compact ? 3 : 4,
4841
- border: "1px solid #f0f0f0",
4842
- boxShadow: "0 4px 24px rgba(0,0,0,0.06)",
4843
5144
  bgcolor: "#fff",
4844
- // height: "100%",
4845
- display: "flex",
4846
- flexDirection: "column"
5145
+ borderRadius: exportMode ? 2 : 4,
5146
+ border: exportMode ? "1px solid #DDE3EA" : "1px solid #f0f0f0",
5147
+ boxShadow: exportMode ? "0 1px 0 rgba(15,23,42,0.03)" : "0 4px 24px rgba(0,0,0,0.06)",
5148
+ p: exportMode ? 1.5 : 3,
5149
+ height: exportMode ? "100%" : "auto",
5150
+ boxSizing: "border-box"
4847
5151
  }, sx),
4848
5152
  children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4849
- sx: {},
4850
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4851
- sx: {
4852
- fontWeight: 700,
4853
- fontSize: compact ? "13px" : "16px",
4854
- color: "#000",
4855
- textAlign: "left",
4856
- lineHeight: 1.15
4857
- },
4858
- children: title
4859
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4860
- sx: {
4861
- fontSize: "12px",
4862
- color: "rgba(0, 0, 0, 0.4)",
4863
- textAlign: "left",
4864
- lineHeight: 1.15
4865
- },
4866
- children: subtitle
4867
- })]
4868
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4869
5153
  sx: {
4870
- height: compact ? 90 : 160,
4871
- position: "relative",
4872
- mt: compact ? 0.5 : 1,
4873
5154
  display: "flex",
4874
- justifyContent: "center"
5155
+ flexDirection: "column"
4875
5156
  },
4876
- children: /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
4877
- options: chartOptions,
4878
- series: series,
4879
- type: "radialBar",
4880
- width: "100%",
4881
- height: "100%"
4882
- })
4883
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4884
- sx: {},
4885
5157
  children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4886
5158
  sx: {
4887
- display: "flex",
4888
- justifyContent: "space-between",
4889
- alignItems: "center"
5159
+ textAlign: "left"
4890
5160
  },
4891
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5161
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4892
5162
  sx: {
4893
- display: "flex",
4894
- alignItems: "center",
4895
- gap: 1
5163
+ fontWeight: 700,
5164
+ fontSize: exportMode ? "12px" : "18px",
5165
+ color: "#000",
5166
+ lineHeight: 1.15
4896
5167
  },
4897
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
4898
- sx: {
4899
- width: 10,
4900
- height: 10,
4901
- bgcolor: chartColors[0],
4902
- borderRadius: "2px"
4903
- }
4904
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4905
- sx: {
4906
- fontSize: "13px",
4907
- color: "rgba(0, 0, 0, 0.5)",
4908
- fontWeight: 500
4909
- },
4910
- children: "Acceptance"
4911
- })]
4912
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5168
+ children: title
5169
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4913
5170
  sx: {
4914
- display: "flex",
4915
- alignItems: "center",
4916
- gap: 0.5
5171
+ fontSize: exportMode ? "9.5px" : "13px",
5172
+ color: exportMode ? "#94A3B8" : "rgba(0, 0, 0, 0.4)",
5173
+ lineHeight: 1.15
4917
5174
  },
4918
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4919
- sx: {
4920
- fontSize: "13px",
4921
- fontWeight: 700,
4922
- color: "#000"
4923
- },
4924
- children: acceptanceVal
4925
- }), /*#__PURE__*/jsxRuntime.jsx(TrendValue, {
4926
- trend: acceptanceTrend
4927
- })]
5175
+ children: subtitle
4928
5176
  })]
4929
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5177
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4930
5178
  sx: {
4931
5179
  display: "flex",
4932
- justifyContent: "space-between",
4933
- alignItems: "center"
5180
+ gap: exportMode ? 1 : 1.5,
5181
+ mt: exportMode ? 0.75 : 0.5,
5182
+ flexWrap: "wrap"
4934
5183
  },
4935
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4936
- sx: {
4937
- display: "flex",
4938
- alignItems: "center",
4939
- gap: 1
4940
- },
4941
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
4942
- sx: {
4943
- width: 10,
4944
- height: 10,
4945
- bgcolor: chartColors[1],
4946
- borderRadius: "2px"
4947
- }
4948
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4949
- sx: {
4950
- fontSize: "13px",
4951
- color: "rgba(0, 0, 0, 0.5)",
4952
- fontWeight: 500
4953
- },
4954
- children: "Raised"
4955
- })]
4956
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4957
- sx: {
4958
- display: "flex",
4959
- alignItems: "center",
4960
- gap: 0.5
4961
- },
4962
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5184
+ children: summaries.map(function (item, index) {
5185
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4963
5186
  sx: {
4964
- fontSize: "13px",
4965
- fontWeight: 700,
4966
- color: "#000"
5187
+ display: "flex",
5188
+ alignItems: "center",
5189
+ gap: 0.5
4967
5190
  },
4968
- children: raisedVal
4969
- }), /*#__PURE__*/jsxRuntime.jsx(TrendValue, {
4970
- trend: raisedTrend
4971
- })]
4972
- })]
5191
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
5192
+ sx: {
5193
+ width: exportMode ? 6 : 8,
5194
+ height: exportMode ? 6 : 8,
5195
+ bgcolor: item.color,
5196
+ borderRadius: "50%"
5197
+ }
5198
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5199
+ sx: {
5200
+ fontSize: exportMode ? "9.5px" : "13px",
5201
+ color: exportMode ? "#374151" : "rgba(0, 0, 0, 0.5)",
5202
+ fontWeight: 500
5203
+ },
5204
+ children: item.label
5205
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
5206
+ sx: {
5207
+ fontSize: exportMode ? "9.5px" : "13px",
5208
+ fontWeight: exportMode ? 700 : 600,
5209
+ color: "#000"
5210
+ },
5211
+ children: ["$", formatNumber(item.total || 0)]
5212
+ })]
5213
+ }, item.label || index);
5214
+ })
4973
5215
  })]
5216
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5217
+ sx: {
5218
+ height: resolvedChartHeight,
5219
+ width: exportMode ? "calc(100% + 24px)" : "calc(100% + 48px)",
5220
+ ml: exportMode ? -1.5 : -3,
5221
+ mr: exportMode ? -1.5 : -3
5222
+ },
5223
+ children: /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
5224
+ options: chartOptions,
5225
+ series: series,
5226
+ type: "bar",
5227
+ height: "100%"
5228
+ })
4974
5229
  })]
4975
5230
  });
4976
5231
  };