@ammarkhalidfarooq/dashboard-package 0.6.64 → 0.6.65

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