@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.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");
@@ -2673,7 +2650,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2673
2650
  data: []
2674
2651
  }];
2675
2652
  var revCats = mainChart.categories || [];
2676
- var campaigns = ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).length ? apiData.activeCampaigns : [{
2653
+ ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).length ? apiData.activeCampaigns : [{
2677
2654
  title: "Orphan sponsorship — Yemen",
2678
2655
  collectedAmount: 78400,
2679
2656
  usdTargetAmount: 100000,
@@ -2709,9 +2686,6 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2709
2686
  averageDonation: 1940,
2710
2687
  status: "Active"
2711
2688
  }];
2712
- var campaignStatusByIndex = campaigns.map(function (c) {
2713
- return c.status || "Active";
2714
- });
2715
2689
  var ob = (apiData === null || apiData === void 0 ? void 0 : apiData.orderBumpDetails) || {};
2716
2690
  var obData = ((ob === null || ob === void 0 ? void 0 : ob.chart) || []).map(function (i) {
2717
2691
  return Number(i.revenue || 0);
@@ -2874,10 +2848,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2874
2848
  gap: 14,
2875
2849
  marginBottom: 6
2876
2850
  },
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];
2851
+ children: [["Email", C.cyan], ["Organic", C.emerald], ["Paid Ads", C.indigo]].map(function (_ref14) {
2852
+ var _ref15 = _slicedToArray(_ref14, 2),
2853
+ name = _ref15[0],
2854
+ color = _ref15[1];
2881
2855
  return /*#__PURE__*/jsxs("div", {
2882
2856
  style: {
2883
2857
  display: "flex",
@@ -2953,12 +2927,12 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
2953
2927
  title: "Active campaigns",
2954
2928
  subtitle: "Live fundraisers ranked by velocity",
2955
2929
  children: /*#__PURE__*/jsx(MiniTable, {
2956
- head: ["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT", "STATUS"],
2957
- colAlign: ["left", "right", "left", "right", "right", "right"],
2930
+ head: ["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT"],
2931
+ colAlign: ["left", "right", "left", "right", "right"],
2958
2932
  rows: activeCampaigns.map(function (c, i) {
2959
2933
  return [c.name, c.val1, /*#__PURE__*/jsx(ProgressBar, {
2960
2934
  value: c.progress
2961
- }, "campaign-progress-".concat(i)), c.val3, c.val4, campaignStatusByIndex[i] || "Active"];
2935
+ }, "campaign-progress-".concat(i)), c.val3, c.val4];
2962
2936
  })
2963
2937
  })
2964
2938
  }), /*#__PURE__*/jsx(Panel, {
@@ -3053,7 +3027,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3053
3027
  style: {
3054
3028
  fontSize: 9
3055
3029
  },
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")
3030
+ 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
3031
  })
3058
3032
  })]
3059
3033
  })]
@@ -3065,10 +3039,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3065
3039
  gridTemplateColumns: "repeat(4, 1fr)",
3066
3040
  gap: 8
3067
3041
  },
3068
- children: [/*#__PURE__*/jsx(DonationTypeBarChart, {
3069
- exportMode: true,
3070
- subtitle: "Donation type \xB7 weekly",
3071
- donationTypeData: report.donationTypeData
3042
+ children: [/*#__PURE__*/jsx(DonationTypePanel, {
3043
+ donationTypeData: report.donationTypeData,
3044
+ recurringColor: C.indigo,
3045
+ oneTimeColor: C.emerald
3072
3046
  }), /*#__PURE__*/jsx(Panel, {
3073
3047
  title: "Donor geography",
3074
3048
  subtitle: "Top countries \xB7 ".concat(formatNumber(totalDonors), " total"),
@@ -3224,10 +3198,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3224
3198
  display: "flex",
3225
3199
  gap: 12
3226
3200
  },
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];
3201
+ 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) {
3202
+ var _ref18 = _slicedToArray(_ref17, 2),
3203
+ l = _ref18[0],
3204
+ v = _ref18[1];
3231
3205
  return /*#__PURE__*/jsxs("div", {
3232
3206
  children: [/*#__PURE__*/jsx("div", {
3233
3207
  style: {
@@ -3354,10 +3328,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref11, ref) {
3354
3328
  display: "flex",
3355
3329
  gap: 12
3356
3330
  },
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];
3331
+ 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) {
3332
+ var _ref20 = _slicedToArray(_ref19, 2),
3333
+ l = _ref20[0],
3334
+ v = _ref20[1];
3361
3335
  return /*#__PURE__*/jsxs("div", {
3362
3336
  children: [/*#__PURE__*/jsx("div", {
3363
3337
  style: {
@@ -4701,274 +4675,555 @@ var MetricSparklineCard = function MetricSparklineCard(_ref) {
4701
4675
  sx: {
4702
4676
  display: "flex",
4703
4677
  justifyContent: "space-between",
4704
- mt: 0.5
4678
+ mt: 0.5
4679
+ },
4680
+ children: axisLabels.map(function (label, idx) {
4681
+ return /*#__PURE__*/jsx(Typography, {
4682
+ sx: {
4683
+ fontSize: "10px",
4684
+ color: "rgba(0, 0, 0, 0.3)"
4685
+ },
4686
+ children: label
4687
+ }, "".concat(label, "-").concat(idx));
4688
+ })
4689
+ })]
4690
+ }), /*#__PURE__*/jsx(Box, {
4691
+ sx: {
4692
+ mt: "auto",
4693
+ pt: bottomSection ? 1.5 : 3,
4694
+ display: "flex",
4695
+ justifyContent: "space-between"
4696
+ },
4697
+ children: footerMetrics.map(function (m, idx) {
4698
+ return /*#__PURE__*/jsxs(Box, {
4699
+ sx: {
4700
+ textAlign: "center"
4701
+ },
4702
+ children: [/*#__PURE__*/jsx(Typography, {
4703
+ sx: {
4704
+ fontSize: "10px",
4705
+ color: "rgba(0, 0, 0, 0.4)",
4706
+ fontWeight: 500
4707
+ },
4708
+ children: m.label
4709
+ }), /*#__PURE__*/jsx(Typography, {
4710
+ sx: {
4711
+ fontSize: "14px",
4712
+ fontWeight: 700,
4713
+ color: "#000"
4714
+ },
4715
+ children: "".concat(formatNumber(m.value))
4716
+ })]
4717
+ }, idx);
4718
+ })
4719
+ })]
4720
+ });
4721
+ };
4722
+
4723
+ var TrendValue = function TrendValue(_ref) {
4724
+ var trend = _ref.trend;
4725
+ var direction = getTrendDirection(trend);
4726
+ var color = getTrendColor(trend);
4727
+ var Icon = direction === "down" ? TrendingDown : TrendingUp;
4728
+ return /*#__PURE__*/jsxs(Typography, {
4729
+ sx: {
4730
+ fontSize: "10px",
4731
+ fontWeight: 700,
4732
+ color: color,
4733
+ display: "flex",
4734
+ alignItems: "center"
4735
+ },
4736
+ children: [/*#__PURE__*/jsx(Icon, {
4737
+ sx: {
4738
+ fontSize: "12px"
4739
+ }
4740
+ }), " ", trend]
4741
+ });
4742
+ };
4743
+ var MetricDonutCard = function MetricDonutCard(_ref2) {
4744
+ var title = _ref2.title,
4745
+ subtitle = _ref2.subtitle,
4746
+ acceptanceRate = _ref2.acceptanceRate,
4747
+ acceptanceVal = _ref2.acceptanceVal,
4748
+ acceptanceTrend = _ref2.acceptanceTrend,
4749
+ raisedVal = _ref2.raisedVal,
4750
+ raisedTrend = _ref2.raisedTrend,
4751
+ _ref2$chartColors = _ref2.chartColors,
4752
+ chartColors = _ref2$chartColors === void 0 ? ["rgb(99, 99, 230)", "#88bfd290"] : _ref2$chartColors,
4753
+ sx = _ref2.sx,
4754
+ _ref2$compact = _ref2.compact,
4755
+ compact = _ref2$compact === void 0 ? false : _ref2$compact;
4756
+ var chartOptions = {
4757
+ chart: {
4758
+ type: "radialBar",
4759
+ sparkline: {
4760
+ enabled: true
4761
+ }
4762
+ },
4763
+ plotOptions: {
4764
+ radialBar: {
4765
+ hollow: {
4766
+ size: "45%"
4767
+ },
4768
+ track: {
4769
+ background: chartColors[1] || "#f0f0f0",
4770
+ strokeWidth: "100%"
4771
+ },
4772
+ dataLabels: {
4773
+ name: {
4774
+ show: true,
4775
+ fontSize: "11px",
4776
+ fontWeight: 500,
4777
+ color: "rgba(0, 0, 0, 0.4)",
4778
+ offsetY: 15
4779
+ },
4780
+ value: {
4781
+ show: true,
4782
+ fontSize: "18px",
4783
+ fontWeight: 700,
4784
+ color: "#000",
4785
+ offsetY: -15,
4786
+ formatter: function formatter() {
4787
+ return acceptanceRate + "%";
4788
+ }
4789
+ }
4790
+ }
4791
+ }
4792
+ },
4793
+ stroke: {
4794
+ lineCap: "butt"
4795
+ },
4796
+ colors: [chartColors[0]],
4797
+ labels: ["accepted"],
4798
+ tooltip: {
4799
+ enabled: true,
4800
+ theme: "dark",
4801
+ y: {
4802
+ formatter: function formatter(val) {
4803
+ return "".concat(val, "%");
4804
+ }
4805
+ }
4806
+ }
4807
+ };
4808
+ var series = [acceptanceRate];
4809
+ return /*#__PURE__*/jsxs(Card, {
4810
+ sx: _objectSpread2({
4811
+ p: compact ? 1.25 : 3,
4812
+ borderRadius: compact ? 3 : 4,
4813
+ border: "1px solid #f0f0f0",
4814
+ boxShadow: "0 4px 24px rgba(0,0,0,0.06)",
4815
+ bgcolor: "#fff",
4816
+ // height: "100%",
4817
+ display: "flex",
4818
+ flexDirection: "column"
4819
+ }, sx),
4820
+ children: [/*#__PURE__*/jsxs(Box, {
4821
+ sx: {},
4822
+ children: [/*#__PURE__*/jsx(Typography, {
4823
+ sx: {
4824
+ fontWeight: 700,
4825
+ fontSize: compact ? "13px" : "16px",
4826
+ color: "#000",
4827
+ textAlign: "left",
4828
+ lineHeight: 1.15
4829
+ },
4830
+ children: title
4831
+ }), /*#__PURE__*/jsx(Typography, {
4832
+ sx: {
4833
+ fontSize: "12px",
4834
+ color: "rgba(0, 0, 0, 0.4)",
4835
+ textAlign: "left",
4836
+ lineHeight: 1.15
4837
+ },
4838
+ children: subtitle
4839
+ })]
4840
+ }), /*#__PURE__*/jsx(Box, {
4841
+ sx: {
4842
+ height: compact ? 90 : 160,
4843
+ position: "relative",
4844
+ mt: compact ? 0.5 : 1,
4845
+ display: "flex",
4846
+ justifyContent: "center"
4847
+ },
4848
+ children: /*#__PURE__*/jsx(ReactApexChart, {
4849
+ options: chartOptions,
4850
+ series: series,
4851
+ type: "radialBar",
4852
+ width: "100%",
4853
+ height: "100%"
4854
+ })
4855
+ }), /*#__PURE__*/jsxs(Box, {
4856
+ sx: {},
4857
+ children: [/*#__PURE__*/jsxs(Box, {
4858
+ sx: {
4859
+ display: "flex",
4860
+ justifyContent: "space-between",
4861
+ alignItems: "center"
4862
+ },
4863
+ children: [/*#__PURE__*/jsxs(Box, {
4864
+ sx: {
4865
+ display: "flex",
4866
+ alignItems: "center",
4867
+ gap: 1
4868
+ },
4869
+ children: [/*#__PURE__*/jsx(Box, {
4870
+ sx: {
4871
+ width: 10,
4872
+ height: 10,
4873
+ bgcolor: chartColors[0],
4874
+ borderRadius: "2px"
4875
+ }
4876
+ }), /*#__PURE__*/jsx(Typography, {
4877
+ sx: {
4878
+ fontSize: "13px",
4879
+ color: "rgba(0, 0, 0, 0.5)",
4880
+ fontWeight: 500
4881
+ },
4882
+ children: "Acceptance"
4883
+ })]
4884
+ }), /*#__PURE__*/jsxs(Box, {
4885
+ sx: {
4886
+ display: "flex",
4887
+ alignItems: "center",
4888
+ gap: 0.5
4889
+ },
4890
+ children: [/*#__PURE__*/jsx(Typography, {
4891
+ sx: {
4892
+ fontSize: "13px",
4893
+ fontWeight: 700,
4894
+ color: "#000"
4895
+ },
4896
+ children: acceptanceVal
4897
+ }), /*#__PURE__*/jsx(TrendValue, {
4898
+ trend: acceptanceTrend
4899
+ })]
4900
+ })]
4901
+ }), /*#__PURE__*/jsxs(Box, {
4902
+ sx: {
4903
+ display: "flex",
4904
+ justifyContent: "space-between",
4905
+ alignItems: "center"
4705
4906
  },
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, {
4907
+ children: [/*#__PURE__*/jsxs(Box, {
4725
4908
  sx: {
4726
- textAlign: "center"
4909
+ display: "flex",
4910
+ alignItems: "center",
4911
+ gap: 1
4727
4912
  },
4728
- children: [/*#__PURE__*/jsx(Typography, {
4913
+ children: [/*#__PURE__*/jsx(Box, {
4729
4914
  sx: {
4730
- fontSize: "10px",
4731
- color: "rgba(0, 0, 0, 0.4)",
4915
+ width: 10,
4916
+ height: 10,
4917
+ bgcolor: chartColors[1],
4918
+ borderRadius: "2px"
4919
+ }
4920
+ }), /*#__PURE__*/jsx(Typography, {
4921
+ sx: {
4922
+ fontSize: "13px",
4923
+ color: "rgba(0, 0, 0, 0.5)",
4732
4924
  fontWeight: 500
4733
4925
  },
4734
- children: m.label
4735
- }), /*#__PURE__*/jsx(Typography, {
4926
+ children: "Raised"
4927
+ })]
4928
+ }), /*#__PURE__*/jsxs(Box, {
4929
+ sx: {
4930
+ display: "flex",
4931
+ alignItems: "center",
4932
+ gap: 0.5
4933
+ },
4934
+ children: [/*#__PURE__*/jsx(Typography, {
4736
4935
  sx: {
4737
- fontSize: "14px",
4936
+ fontSize: "13px",
4738
4937
  fontWeight: 700,
4739
4938
  color: "#000"
4740
4939
  },
4741
- children: "".concat(formatNumber(m.value))
4940
+ children: raisedVal
4941
+ }), /*#__PURE__*/jsx(TrendValue, {
4942
+ trend: raisedTrend
4742
4943
  })]
4743
- }, idx);
4744
- })
4944
+ })]
4945
+ })]
4745
4946
  })]
4746
4947
  });
4747
4948
  };
4748
4949
 
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;
4950
+ var DonationTypeBarChart = function DonationTypeBarChart(_ref) {
4951
+ var sx = _ref.sx,
4952
+ donationTypeData = _ref.donationTypeData,
4953
+ _ref$exportMode = _ref.exportMode,
4954
+ exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode,
4955
+ _ref$subtitle = _ref.subtitle,
4956
+ subtitle = _ref$subtitle === void 0 ? "Donation type" : _ref$subtitle,
4957
+ chartHeight = _ref.chartHeight;
4958
+ var recurringColor = "rgb(99, 99, 230)";
4959
+ var oneTimeColor = "#10B981";
4960
+ var colors = [recurringColor, oneTimeColor, "#06B6D4", "#F59E0B", "#EF4444"];
4961
+ var categories = [];
4962
+ var series = [];
4963
+ var summaries = [];
4964
+ var title = "Donation Type";
4965
+ var isDistributed = false;
4966
+ if (donationTypeData && donationTypeData.data && Array.isArray(donationTypeData.data)) {
4967
+ // Time series recurring vs one-time format
4968
+ categories = donationTypeData.data.map(function (item) {
4969
+ return item.label || "";
4970
+ });
4971
+ series = [{
4972
+ name: "Recurring",
4973
+ data: donationTypeData.data.map(function (item) {
4974
+ return item.recurring || 0;
4975
+ })
4976
+ }, {
4977
+ name: "One-time",
4978
+ data: donationTypeData.data.map(function (item) {
4979
+ return item.oneTime || 0;
4980
+ })
4981
+ }];
4982
+ summaries = [{
4983
+ label: "Recurring",
4984
+ total: donationTypeData.totalRecurringDonations || 0,
4985
+ color: recurringColor
4986
+ }, {
4987
+ label: "One-time",
4988
+ total: donationTypeData.totalOneTimeDonations || 0,
4989
+ color: oneTimeColor
4990
+ }];
4991
+ title = "Recurring vs One-time";
4992
+ isDistributed = false;
4993
+ } else if (Array.isArray(donationTypeData) && donationTypeData.length > 0 && donationTypeData[0].totalAmount !== undefined) {
4994
+ // New array format
4995
+ categories = donationTypeData.map(function (item) {
4996
+ return item.type || "";
4997
+ });
4998
+ series = [{
4999
+ name: "Amount",
5000
+ data: donationTypeData.map(function (item) {
5001
+ return item.totalAmount || 0;
5002
+ })
5003
+ }];
5004
+ summaries = donationTypeData.map(function (item, index) {
5005
+ return {
5006
+ label: item.type || "",
5007
+ total: item.totalAmount || 0,
5008
+ color: colors[index % colors.length]
5009
+ };
5010
+ });
5011
+ isDistributed = true;
5012
+ if (donationTypeData.length === 2) {
5013
+ title = "".concat(donationTypeData[0].type, " vs ").concat(donationTypeData[1].type);
5014
+ }
5015
+ } else {
5016
+ var _dataObj$summary, _dataObj$summary2, _dataObj$summary3, _dataObj$summary4;
5017
+ // Object format, empty array, or missing data
5018
+ var dataObj = donationTypeData && _typeof(donationTypeData) === "object" && !Array.isArray(donationTypeData) ? donationTypeData : {};
5019
+ categories = dataObj.categories || [];
5020
+ var rawSeries = dataObj.series || [];
5021
+ if (rawSeries.length && categories.length) {
5022
+ series = rawSeries;
5023
+ } else {
5024
+ series = [{
5025
+ name: "Recurring",
5026
+ data: []
5027
+ }, {
5028
+ name: "One-time",
5029
+ data: []
5030
+ }];
5031
+ }
5032
+ summaries = [{
5033
+ 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",
5034
+ 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,
5035
+ color: recurringColor
5036
+ }, {
5037
+ 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",
5038
+ 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,
5039
+ color: oneTimeColor
5040
+ }];
5041
+ title = "Recurring vs one-time";
5042
+ isDistributed = false;
5043
+ }
5044
+ var resolvedChartHeight = chartHeight !== null && chartHeight !== void 0 ? chartHeight : exportMode ? 110 : 170;
4782
5045
  var chartOptions = {
4783
5046
  chart: {
4784
- type: "radialBar",
4785
- sparkline: {
4786
- enabled: true
5047
+ type: "bar",
5048
+ toolbar: {
5049
+ show: false
5050
+ },
5051
+ zoom: {
5052
+ enabled: false
5053
+ },
5054
+ fontFamily: "Inter, sans-serif"
5055
+ },
5056
+ plotOptions: {
5057
+ bar: {
5058
+ horizontal: false,
5059
+ columnWidth: exportMode ? "68%" : "75%",
5060
+ borderRadius: exportMode ? 3 : 4,
5061
+ distributed: isDistributed,
5062
+ dataLabels: {
5063
+ position: "top"
5064
+ }
5065
+ }
5066
+ },
5067
+ dataLabels: {
5068
+ enabled: true,
5069
+ formatter: function formatter(val) {
5070
+ return "$".concat(formatNumber(val));
5071
+ },
5072
+ offsetY: exportMode ? -16 : -20,
5073
+ style: {
5074
+ fontSize: exportMode ? "7px" : "9px",
5075
+ fontWeight: 600,
5076
+ colors: ["#000"]
5077
+ }
5078
+ },
5079
+ stroke: {
5080
+ show: true,
5081
+ width: 2,
5082
+ colors: ["transparent"]
5083
+ },
5084
+ xaxis: {
5085
+ categories: categories,
5086
+ axisBorder: {
5087
+ show: false
5088
+ },
5089
+ axisTicks: {
5090
+ show: false
5091
+ },
5092
+ labels: {
5093
+ style: {
5094
+ colors: "rgba(0, 0, 0, 0.4)",
5095
+ fontSize: exportMode ? "8px" : "11px"
5096
+ }
4787
5097
  }
4788
5098
  },
4789
- plotOptions: {
4790
- radialBar: {
4791
- hollow: {
4792
- size: "45%"
4793
- },
4794
- track: {
4795
- background: chartColors[1] || "#f0f0f0",
4796
- strokeWidth: "100%"
5099
+ yaxis: {
5100
+ min: 0,
5101
+ tickAmount: exportMode ? 3 : 4,
5102
+ labels: {
5103
+ formatter: function formatter(val) {
5104
+ return "$".concat(formatNumber(val));
4797
5105
  },
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
- }
5106
+ style: {
5107
+ colors: "rgba(0, 0, 0, 0.4)",
5108
+ fontSize: exportMode ? "8px" : "10px"
4816
5109
  }
4817
5110
  }
4818
5111
  },
4819
- stroke: {
4820
- lineCap: "butt"
5112
+ fill: {
5113
+ opacity: 1
5114
+ },
5115
+ colors: colors,
5116
+ grid: {
5117
+ borderColor: "#f1f1f1",
5118
+ strokeDashArray: 4,
5119
+ padding: {
5120
+ left: 0,
5121
+ right: 0
5122
+ },
5123
+ yaxis: {
5124
+ lines: {
5125
+ show: true
5126
+ }
5127
+ }
5128
+ },
5129
+ legend: {
5130
+ show: false
4821
5131
  },
4822
- colors: [chartColors[0]],
4823
- labels: ["accepted"],
4824
5132
  tooltip: {
4825
- enabled: true,
4826
- theme: "dark",
4827
5133
  y: {
4828
5134
  formatter: function formatter(val) {
4829
- return "".concat(val, "%");
5135
+ return "$".concat(formatNumber(val));
4830
5136
  }
4831
5137
  }
4832
5138
  }
4833
5139
  };
4834
- var series = [acceptanceRate];
4835
5140
  return /*#__PURE__*/jsxs(Card, {
4836
5141
  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
5142
  bgcolor: "#fff",
4842
- // height: "100%",
4843
- display: "flex",
4844
- flexDirection: "column"
5143
+ borderRadius: exportMode ? 2 : 4,
5144
+ border: exportMode ? "1px solid #DDE3EA" : "1px solid #f0f0f0",
5145
+ boxShadow: exportMode ? "0 1px 0 rgba(15,23,42,0.03)" : "0 4px 24px rgba(0,0,0,0.06)",
5146
+ p: exportMode ? 1.5 : 3,
5147
+ height: exportMode ? "100%" : "auto",
5148
+ boxSizing: "border-box"
4845
5149
  }, sx),
4846
5150
  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
5151
  sx: {
4868
- height: compact ? 90 : 160,
4869
- position: "relative",
4870
- mt: compact ? 0.5 : 1,
4871
5152
  display: "flex",
4872
- justifyContent: "center"
5153
+ flexDirection: "column"
4873
5154
  },
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
5155
  children: [/*#__PURE__*/jsxs(Box, {
4884
5156
  sx: {
4885
- display: "flex",
4886
- justifyContent: "space-between",
4887
- alignItems: "center"
5157
+ textAlign: "left"
4888
5158
  },
4889
- children: [/*#__PURE__*/jsxs(Box, {
5159
+ children: [/*#__PURE__*/jsx(Typography, {
4890
5160
  sx: {
4891
- display: "flex",
4892
- alignItems: "center",
4893
- gap: 1
5161
+ fontWeight: 700,
5162
+ fontSize: exportMode ? "12px" : "18px",
5163
+ color: "#000",
5164
+ lineHeight: 1.15
4894
5165
  },
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, {
5166
+ children: title
5167
+ }), /*#__PURE__*/jsx(Typography, {
4911
5168
  sx: {
4912
- display: "flex",
4913
- alignItems: "center",
4914
- gap: 0.5
5169
+ fontSize: exportMode ? "9.5px" : "13px",
5170
+ color: exportMode ? "#94A3B8" : "rgba(0, 0, 0, 0.4)",
5171
+ lineHeight: 1.15
4915
5172
  },
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
- })]
5173
+ children: subtitle
4926
5174
  })]
4927
- }), /*#__PURE__*/jsxs(Box, {
5175
+ }), /*#__PURE__*/jsx(Box, {
4928
5176
  sx: {
4929
5177
  display: "flex",
4930
- justifyContent: "space-between",
4931
- alignItems: "center"
5178
+ gap: exportMode ? 1 : 1.5,
5179
+ mt: exportMode ? 0.75 : 0.5,
5180
+ flexWrap: "wrap"
4932
5181
  },
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, {
5182
+ children: summaries.map(function (item, index) {
5183
+ return /*#__PURE__*/jsxs(Box, {
4961
5184
  sx: {
4962
- fontSize: "13px",
4963
- fontWeight: 700,
4964
- color: "#000"
5185
+ display: "flex",
5186
+ alignItems: "center",
5187
+ gap: 0.5
4965
5188
  },
4966
- children: raisedVal
4967
- }), /*#__PURE__*/jsx(TrendValue, {
4968
- trend: raisedTrend
4969
- })]
4970
- })]
5189
+ children: [/*#__PURE__*/jsx(Box, {
5190
+ sx: {
5191
+ width: exportMode ? 6 : 8,
5192
+ height: exportMode ? 6 : 8,
5193
+ bgcolor: item.color,
5194
+ borderRadius: "50%"
5195
+ }
5196
+ }), /*#__PURE__*/jsx(Typography, {
5197
+ sx: {
5198
+ fontSize: exportMode ? "9.5px" : "13px",
5199
+ color: exportMode ? "#374151" : "rgba(0, 0, 0, 0.5)",
5200
+ fontWeight: 500
5201
+ },
5202
+ children: item.label
5203
+ }), /*#__PURE__*/jsxs(Typography, {
5204
+ sx: {
5205
+ fontSize: exportMode ? "9.5px" : "13px",
5206
+ fontWeight: exportMode ? 700 : 600,
5207
+ color: "#000"
5208
+ },
5209
+ children: ["$", formatNumber(item.total || 0)]
5210
+ })]
5211
+ }, item.label || index);
5212
+ })
4971
5213
  })]
5214
+ }), /*#__PURE__*/jsx(Box, {
5215
+ sx: {
5216
+ height: resolvedChartHeight,
5217
+ width: exportMode ? "calc(100% + 24px)" : "calc(100% + 48px)",
5218
+ ml: exportMode ? -1.5 : -3,
5219
+ mr: exportMode ? -1.5 : -3
5220
+ },
5221
+ children: /*#__PURE__*/jsx(ReactApexChart, {
5222
+ options: chartOptions,
5223
+ series: series,
5224
+ type: "bar",
5225
+ height: "100%"
5226
+ })
4972
5227
  })]
4973
5228
  });
4974
5229
  };