@ammarkhalidfarooq/dashboard-package 0.5.39 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -5,10 +5,10 @@ var material = require('@mui/material');
5
5
  var iconsMaterial = require('@mui/icons-material');
6
6
  var styles = require('@mui/material/styles');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
- var ReactApexChart = require('react-apexcharts');
9
8
  var Grid = require('@mui/material/Grid');
10
9
  var Box = require('@mui/material/Box');
11
10
  var Typography = require('@mui/material/Typography');
11
+ var ReactApexChart = require('react-apexcharts');
12
12
 
13
13
  var theme = styles.createTheme({
14
14
  cssVariables: true,
@@ -891,604 +891,73 @@ var Dashboard = function Dashboard(_ref) {
891
891
  });
892
892
  };
893
893
 
894
- function formatNumber(num) {
895
- if (num >= 1000000000) {
896
- return (num / 1000000000).toFixed(1).replace(/\.0$/, "") + "B";
897
- }
898
- if (num >= 1000000) {
899
- return (num / 1000000).toFixed(1).replace(/\.0$/, "") + "M";
900
- }
901
- if (num >= 1000) {
902
- return (num / 1000).toFixed(1).replace(/\.0$/, "") + "K";
903
- }
904
- return (num !== null && num !== void 0 ? num : 0).toString();
905
- }
906
-
907
- var PURPLE = "#6363E6";
908
- var REPORT_COLORS = {
909
- purple: PURPLE};
910
- var formatTrend = function formatTrend(value) {
911
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "percent";
912
- var n = Number(value !== null && value !== void 0 ? value : 0);
913
- var sign = n >= 0 ? "+" : "";
914
- if (type === "pp") return "".concat(sign).concat(n.toFixed(2), "pp");
915
- if (type === "x") return "".concat(sign).concat(n.toFixed(1), "x");
916
- if (type === "percent") return "".concat(sign).concat(n.toFixed(1), "%");
917
- return "".concat(sign).concat(n);
918
- };
919
- var trendPillSx = function trendPillSx(value) {
920
- var n = Number(value !== null && value !== void 0 ? value : 0);
921
- var positive = n >= 0;
922
- return {
923
- display: "inline-flex",
924
- alignItems: "center",
925
- px: 1.25,
926
- py: 0.35,
927
- borderRadius: "100px",
928
- fontSize: "12px",
929
- fontWeight: 600,
930
- lineHeight: 1.4,
931
- bgcolor: positive ? "#D1FAE5" : "#FEE2E2",
932
- color: positive ? "#047857" : "#DC2626",
933
- whiteSpace: "nowrap"
934
- };
935
- };
936
- var getActiveFilterChips = function getActiveFilterChips(apiData) {
937
- if (Array.isArray(apiData === null || apiData === void 0 ? void 0 : apiData.activeFilterChips) && apiData.activeFilterChips.length) {
938
- return apiData.activeFilterChips;
939
- }
940
- if (typeof (apiData === null || apiData === void 0 ? void 0 : apiData.activeFilters) === "string" && apiData.activeFilters) {
941
- return apiData.activeFilters.split("·").map(function (s) {
942
- return s.trim();
943
- }).filter(Boolean);
944
- }
945
- return ["Status: Successful", "Country: United States, UAE", "Amount: $50 – $5,000"];
946
- };
947
- var buildReportData = function buildReportData() {
948
- var _apiData$overviewStat, _overview$totalRevenu, _overview$netRevenue, _overview$totalDonati, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _growth$overallAVGDon, _growth$totalRevenue, _growth$netRevenue, _growth$totalDonation, _growth$overallAVGDon2, _apiData$medianGift, _apiData$topDecileGif, _apiData$roasCard, _apiData$roasCardPrev, _apiData$adSpend, _apiData$attributedRe, _growth$conversionRat, _refundsRaw$refundRat, _refundsRaw$refundRat2, _refundsRaw$refundCou, _apiData$overviewStat2, _growth$totalRevenue2;
949
- var apiData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
950
- var dateName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Last Period";
951
- var overview = (apiData === null || apiData === void 0 || (_apiData$overviewStat = apiData.overviewStats) === null || _apiData$overviewStat === void 0 ? void 0 : _apiData$overviewStat.overview) || {};
952
- var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
953
- var refundsRaw = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
954
- var totalRaised = Number((_overview$totalRevenu = overview === null || overview === void 0 ? void 0 : overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 240938);
955
- var netRaised = Number((_overview$netRevenue = overview === null || overview === void 0 ? void 0 : overview.netRevenue) !== null && _overview$netRevenue !== void 0 ? _overview$netRevenue : 222300);
956
- var totalDonors = Number((_overview$totalDonati = overview === null || overview === void 0 ? void 0 : overview.totalDonations) !== null && _overview$totalDonati !== void 0 ? _overview$totalDonati : 215);
957
- var avgDonation = Number((_overview$overallAVGD = overview === null || overview === void 0 ? void 0 : overview.overallAVGDonations) !== null && _overview$overallAVGD !== void 0 ? _overview$overallAVGD : 130.58);
958
- var convRate = Number((_overview$conversionR = overview === null || overview === void 0 ? void 0 : overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 1.7);
959
- var totalVisits = Number((_apiData$totalVisits = apiData === null || apiData === void 0 ? void 0 : apiData.totalVisits) !== null && _apiData$totalVisits !== void 0 ? _apiData$totalVisits : 12438);
960
- var passThrough = totalRaised > 0 ? "".concat((netRaised / totalRaised * 100).toFixed(1), "% pass-through") : "92.3% pass-through";
961
- var donorMixRaw = apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData;
962
- var newDonors = 31;
963
- var returningDonors = 184;
964
- var avgGift = avgDonation;
965
- var donorMixPrev = Number((_growth$overallAVGDon = growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _growth$overallAVGDon !== void 0 ? _growth$overallAVGDon : 8.4);
966
- if (Array.isArray(donorMixRaw)) {
967
- var nd = donorMixRaw.find(function (d) {
968
- return /new/i.test(d.type);
969
- }) || {};
970
- var rd = donorMixRaw.find(function (d) {
971
- return /returning/i.test(d.type);
972
- }) || {};
973
- newDonors = nd.totalDonations || 0;
974
- returningDonors = rd.totalDonations || 0;
975
- var totAmt = (nd.totalAmount || 0) + (rd.totalAmount || 0);
976
- var totCnt = newDonors + returningDonors;
977
- avgGift = totCnt > 0 ? totAmt / totCnt : avgDonation;
978
- } else if (donorMixRaw && _typeof(donorMixRaw) === "object") {
979
- newDonors = donorMixRaw.newDonors || 0;
980
- returningDonors = donorMixRaw.returningDonors || 0;
981
- avgGift = donorMixRaw.avgGift || avgDonation;
982
- donorMixPrev = donorMixRaw.donorMixPrev || donorMixPrev;
983
- }
984
- var totalMix = newDonors + returningDonors || 1;
985
- var newPct = Math.round(newDonors / totalMix * 100);
986
- var retPct = 100 - newPct;
987
- var hero = {
988
- value: "$".concat(formatNumber(totalRaised)),
989
- trend: "".concat(formatTrend((_growth$totalRevenue = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue !== void 0 ? _growth$totalRevenue : 18), " vs ").concat(dateName || "last month"),
990
- detail: "".concat(passThrough, " \xB7 ").concat(formatNumber(totalDonors), " donors \xB7 $").concat(formatNumber(avgDonation), " avg \xB7 ").concat(formatNumber(totalVisits), " visits")
991
- };
992
- var metrics = [{
993
- title: "Net Raised",
994
- value: "$".concat(formatNumber(netRaised)),
995
- trend: formatTrend((_growth$netRevenue = growth === null || growth === void 0 ? void 0 : growth.netRevenue) !== null && _growth$netRevenue !== void 0 ? _growth$netRevenue : 17.4),
996
- detail: passThrough
997
- }, {
998
- title: "Total Donors",
999
- value: formatNumber(totalDonors),
1000
- trend: formatTrend((_growth$totalDonation = growth === null || growth === void 0 ? void 0 : growth.totalDonations) !== null && _growth$totalDonation !== void 0 ? _growth$totalDonation : 16.8),
1001
- detail: "".concat(formatNumber(newDonors), " new \xB7 ").concat(formatNumber(returningDonors), " returning")
1002
- }, {
1003
- title: "Avg Donation",
1004
- value: "$".concat(formatNumber(avgDonation)),
1005
- trend: formatTrend((_growth$overallAVGDon2 = growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _growth$overallAVGDon2 !== void 0 ? _growth$overallAVGDon2 : 8.4),
1006
- detail: "Median $".concat(formatNumber((_apiData$medianGift = apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) !== null && _apiData$medianGift !== void 0 ? _apiData$medianGift : 75), " \xB7 top decile $").concat(formatNumber((_apiData$topDecileGif = apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) !== null && _apiData$topDecileGif !== void 0 ? _apiData$topDecileGif : 850))
1007
- }, {
1008
- title: "ROAS",
1009
- value: "".concat(formatNumber((_apiData$roasCard = apiData === null || apiData === void 0 ? void 0 : apiData.roasCard) !== null && _apiData$roasCard !== void 0 ? _apiData$roasCard : 3.0), "x"),
1010
- trend: formatTrend((_apiData$roasCardPrev = apiData === null || apiData === void 0 ? void 0 : apiData.roasCardPrev) !== null && _apiData$roasCardPrev !== void 0 ? _apiData$roasCardPrev : 0.4, "x"),
1011
- detail: "$".concat(formatNumber((_apiData$adSpend = apiData === null || apiData === void 0 ? void 0 : apiData.adSpend) !== null && _apiData$adSpend !== void 0 ? _apiData$adSpend : 72000), " spend \xB7 $").concat(formatNumber((_apiData$attributedRe = apiData === null || apiData === void 0 ? void 0 : apiData.attributedRevenue) !== null && _apiData$attributedRe !== void 0 ? _apiData$attributedRe : 215000), " attrib.")
1012
- }, {
1013
- title: "Conversion",
1014
- value: "".concat(formatNumber(convRate), "%"),
1015
- trend: formatTrend((_growth$conversionRat = growth === null || growth === void 0 ? void 0 : growth.conversionRate) !== null && _growth$conversionRat !== void 0 ? _growth$conversionRat : 0.21, "pp"),
1016
- detail: "".concat(formatNumber(totalDonors), " from ").concat(formatNumber(totalVisits), " visits")
1017
- }, {
1018
- title: "Refund Rate",
1019
- value: "".concat(Number((_refundsRaw$refundRat = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRate) !== null && _refundsRaw$refundRat !== void 0 ? _refundsRaw$refundRat : 0.84).toFixed(2), "%"),
1020
- trend: formatTrend((_refundsRaw$refundRat2 = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange) !== null && _refundsRaw$refundRat2 !== void 0 ? _refundsRaw$refundRat2 : -0.3, "pp"),
1021
- detail: "".concat(formatNumber((_refundsRaw$refundCou = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundCount) !== null && _refundsRaw$refundCou !== void 0 ? _refundsRaw$refundCou : 2), " refunds this period"),
1022
- trendPositiveWhenNegative: true
1023
- }];
1024
- var stackedTR = (apiData === null || apiData === void 0 || (_apiData$overviewStat2 = apiData.overviewStats) === null || _apiData$overviewStat2 === void 0 ? void 0 : _apiData$overviewStat2.totalRaised) || {};
1025
- var hasStackedData = (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic);
1026
- var mainChart = {
1027
- label: "Total revenue trend",
1028
- subtitle: "Last 30 days · daily aggregation",
1029
- value: "$".concat(formatNumber(totalRaised)),
1030
- trend: "".concat(formatTrend((_growth$totalRevenue2 = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue2 !== void 0 ? _growth$totalRevenue2 : 18), " vs ").concat(dateName || "last month"),
1031
- hideControls: true,
1032
- stacked: true,
1033
- colors: ["#6366F1", "#10B981", "#06B6D4"],
1034
- stroke: {
1035
- curve: "smooth",
1036
- width: 3
1037
- }
1038
- };
1039
- if (hasStackedData) {
1040
- var categories = ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || []).map(function (item) {
1041
- return item.date;
1042
- });
1043
- mainChart = _objectSpread2(_objectSpread2({}, mainChart), {}, {
1044
- series: [{
1045
- name: "Paid Ads",
1046
- data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || []).map(function (item) {
1047
- return item.value;
1048
- })
1049
- }, {
1050
- name: "Organic",
1051
- data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic) || []).map(function (item) {
1052
- return item.value;
1053
- })
1054
- }, {
1055
- name: "Email",
1056
- data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || []).map(function (item) {
1057
- return item.value;
1058
- })
1059
- }],
1060
- categories: categories
1061
- });
1062
- } else {
1063
- var _categories = (apiData === null || apiData === void 0 ? void 0 : apiData.categories) || ["Apr 5", "Apr 11", "Apr 17", "Apr 23", "Apr 29", "May 4"];
1064
- var base = (apiData === null || apiData === void 0 ? void 0 : apiData.revenueData) || [3000, 4500, 5200, 5800, 6200, 7100, 8500, 9200, 9500];
1065
- mainChart = _objectSpread2(_objectSpread2({}, mainChart), {}, {
1066
- series: [{
1067
- name: "Paid Ads",
1068
- data: base.map(function (v) {
1069
- return v * 0.55;
1070
- })
1071
- }, {
1072
- name: "Organic",
1073
- data: base.map(function (v) {
1074
- return v * 0.28;
1075
- })
1076
- }, {
1077
- name: "Email",
1078
- data: base.map(function (v) {
1079
- return v * 0.17;
1080
- })
1081
- }],
1082
- categories: _categories
1083
- });
1084
- }
1085
- var sampleCampaigns = [{
1086
- title: "Orphan sponsorship — Yemen",
1087
- collectedAmount: 78400,
1088
- usdTargetAmount: 100000,
1089
- uniqueDonationsCount: 82,
1090
- status: "Active"
1091
- }, {
1092
- title: "Emergency food — Gaza",
1093
- collectedAmount: 62100,
1094
- usdTargetAmount: 75000,
1095
- uniqueDonationsCount: 61,
1096
- status: "Active"
1097
- }, {
1098
- title: "Masjid build — Somalia",
1099
- collectedAmount: 38200,
1100
- usdTargetAmount: 83000,
1101
- uniqueDonationsCount: 34,
1102
- status: "Slow"
1103
- }, {
1104
- title: "Water wells — Pakistan",
1105
- collectedAmount: 29800,
1106
- usdTargetAmount: 30000,
1107
- uniqueDonationsCount: 28,
1108
- status: "Closing"
1109
- }, {
1110
- title: "Ramadan packs — Egypt",
1111
- collectedAmount: 18400,
1112
- usdTargetAmount: 23500,
1113
- uniqueDonationsCount: 10,
1114
- status: "Active"
1115
- }];
1116
- var campaignSource = ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).length ? apiData.activeCampaigns : sampleCampaigns;
1117
- var activeCampaigns = campaignSource.map(function (campaign) {
1118
- return {
1119
- id: campaign.campaignName ? campaign.campaignName.split(" ").filter(Boolean).map(function (w) {
1120
- return w[0];
1121
- }).join("").toUpperCase().slice(0, 2) : "??",
1122
- name: campaign.title || "Untitled Campaign",
1123
- val1: "$".concat(formatNumber(campaign.collectedAmount || 0)),
1124
- type: "progress",
1125
- progress: Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100),
1126
- val3: formatNumber(campaign.uniqueDonationsCount || 0),
1127
- val4: "$".concat(formatNumber(campaign.avgGift || 0))
1128
- };
1129
- });
1130
- return {
1131
- hero: hero,
1132
- metrics: metrics,
1133
- mainChart: mainChart,
1134
- growth: growth,
1135
- totalDonors: totalDonors,
1136
- donorMix: {
1137
- newDonors: newDonors,
1138
- returningDonors: returningDonors,
1139
- totalMix: totalMix,
1140
- newPct: newPct,
1141
- retPct: retPct,
1142
- avgGift: avgGift,
1143
- donorMixPrev: donorMixPrev
1144
- },
1145
- activeCampaigns: activeCampaigns,
1146
- donationTypeData: (apiData === null || apiData === void 0 ? void 0 : apiData.recurringBarChartData) || [],
1147
- donorGeographyData: (apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography) || [],
1148
- trafficSourceData: (apiData === null || apiData === void 0 ? void 0 : apiData.trafficSourceData) || [],
1149
- orderBumpData: (apiData === null || apiData === void 0 ? void 0 : apiData.orderBumpDetails) || [],
1150
- upsellData: (apiData === null || apiData === void 0 ? void 0 : apiData.upSellDetails) || {},
1151
- downsellData: (apiData === null || apiData === void 0 ? void 0 : apiData.downSellDetails) || {},
1152
- referralData: (apiData === null || apiData === void 0 ? void 0 : apiData.referralDetails) || {},
1153
- refundsChargebacksData: (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || []
1154
- };
1155
- };
1156
-
1157
- var ReportHeader = function ReportHeader(_ref) {
1158
- var dateName = _ref.dateName,
1159
- _ref$activeFilterChip = _ref.activeFilterChips,
1160
- activeFilterChips = _ref$activeFilterChip === void 0 ? [] : _ref$activeFilterChip,
1161
- _ref$exportMode = _ref.exportMode,
1162
- exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode;
1163
- var now = new Date();
1164
- var generatedLabel = now.toLocaleDateString("en-US", {
1165
- month: "short",
1166
- day: "numeric",
1167
- year: "numeric"
1168
- }) + " · " + now.toLocaleTimeString("en-US", {
1169
- hour: "2-digit",
1170
- minute: "2-digit"
1171
- }) + " GMT";
894
+ var ActiveCampaignsCard = function ActiveCampaignsCard(_ref) {
895
+ var _ref$title = _ref.title,
896
+ title = _ref$title === void 0 ? "Active campaigns" : _ref$title,
897
+ _ref$subtitle = _ref.subtitle,
898
+ subtitle = _ref$subtitle === void 0 ? "Live fundraisers ranked by velocity" : _ref$subtitle,
899
+ actionLabel = _ref.actionLabel,
900
+ _ref$columns = _ref.columns,
901
+ columns = _ref$columns === void 0 ? ["Campaign", "Raised", "Progress", "Donors", "Avg gift"] : _ref$columns,
902
+ _ref$rows = _ref.rows,
903
+ rows = _ref$rows === void 0 ? [] : _ref$rows,
904
+ _ref$gridTemplateColu = _ref.gridTemplateColumns,
905
+ gridTemplateColumns = _ref$gridTemplateColu === void 0 ? "3fr 1fr 1.5fr 0.8fr 1fr " : _ref$gridTemplateColu,
906
+ height = _ref.height,
907
+ _ref$compact = _ref.compact,
908
+ compact = _ref$compact === void 0 ? false : _ref$compact;
1172
909
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1173
910
  sx: {
1174
- mb: exportMode ? 1.5 : 3
911
+ bgcolor: "#fff",
912
+ borderRadius: compact ? 3 : 4,
913
+ border: "1px solid #f0f0f0",
914
+ boxShadow: compact ? "0 2px 12px rgba(0,0,0,0.05)" : "0 4px 24px rgba(0,0,0,0.06)",
915
+ p: compact ? 1.5 : 3,
916
+ height: height
917
+ // height: "100%",
1175
918
  },
1176
919
  children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1177
920
  sx: {
1178
921
  display: "flex",
1179
922
  justifyContent: "space-between",
1180
923
  alignItems: "flex-start",
1181
- flexWrap: "wrap",
1182
- gap: exportMode ? 1 : 2,
1183
- mb: exportMode ? 1.25 : 2.5
924
+ mb: compact ? 1.25 : 3
1184
925
  },
1185
926
  children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1186
927
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1187
928
  sx: {
1188
- fontSize: exportMode ? 26 : {
1189
- xs: 28,
1190
- md: 32
1191
- },
1192
- fontWeight: 800,
1193
- color: REPORT_COLORS.purple,
1194
- letterSpacing: "-0.5px",
1195
- lineHeight: 1.1
1196
- },
1197
- children: "MaDinah"
1198
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1199
- sx: {
1200
- fontSize: 11,
1201
929
  fontWeight: 700,
1202
- letterSpacing: "1.6px",
1203
- color: "#9CA3AF",
1204
- textTransform: "uppercase",
1205
- mt: 0.5
1206
- },
1207
- children: "Performance Report"
1208
- })]
1209
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1210
- sx: {
1211
- textAlign: {
1212
- xs: "left",
1213
- sm: "right"
1214
- }
1215
- },
1216
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1217
- sx: {
1218
- fontSize: 14,
1219
- color: "#6B7280",
1220
- mb: 0.5
930
+ fontSize: compact ? "14px" : "18px",
931
+ color: "#000",
932
+ textAlign: "left"
1221
933
  },
1222
- children: "Dashboard overview \u2014 Overall"
934
+ children: title
1223
935
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1224
936
  sx: {
1225
- fontSize: exportMode ? 16 : {
1226
- xs: 18,
1227
- md: 20
1228
- },
1229
- fontWeight: 700,
1230
- color: "#111827",
1231
- mb: 0.5
1232
- },
1233
- children: dateName
1234
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
1235
- sx: {
1236
- fontSize: exportMode ? 10 : 12,
1237
- color: "#9CA3AF"
937
+ fontSize: compact ? "10px" : "13px",
938
+ color: "rgba(0, 0, 0, 0.4)",
939
+ mt: 0.2
1238
940
  },
1239
- children: ["30-day window \xB7 Generated ", generatedLabel]
941
+ children: subtitle
1240
942
  })]
1241
- })]
1242
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1243
- sx: {
1244
- display: "flex",
1245
- alignItems: "center",
1246
- flexWrap: "wrap",
1247
- gap: 1.25,
1248
- bgcolor: "#F3F4F6",
1249
- borderRadius: "12px",
1250
- px: 2,
1251
- py: 1.25
1252
- },
1253
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1254
- sx: {
1255
- fontSize: 11,
1256
- fontWeight: 700,
1257
- letterSpacing: "0.6px",
1258
- color: "#6B7280",
1259
- textTransform: "uppercase",
1260
- mr: 0.5
1261
- },
1262
- children: "Active Filters"
1263
- }), activeFilterChips.map(function (chip) {
1264
- return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1265
- sx: {
1266
- px: 1.5,
1267
- py: 0.5,
1268
- borderRadius: "100px",
1269
- border: "1px solid ".concat(REPORT_COLORS.purple),
1270
- bgcolor: "#fff",
1271
- fontSize: 12,
1272
- fontWeight: 500,
1273
- color: REPORT_COLORS.purple
1274
- },
1275
- children: chip
1276
- }, chip);
1277
- })]
1278
- })]
1279
- });
1280
- };
1281
-
1282
- var TrendPill = function TrendPill(_ref) {
1283
- var value = _ref.value,
1284
- _ref$trendPositiveWhe = _ref.trendPositiveWhenNegative,
1285
- trendPositiveWhenNegative = _ref$trendPositiveWhe === void 0 ? false : _ref$trendPositiveWhe;
1286
- var n = Number(String(value).replace(/[^0-9.-]/g, "") || 0);
1287
- var positive = trendPositiveWhenNegative ? n <= 0 : n >= 0;
1288
- return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1289
- sx: _objectSpread2({}, trendPillSx(positive ? 1 : -1)),
1290
- children: value
1291
- });
1292
- };
1293
- var MetricCard$1 = function MetricCard(_ref2) {
1294
- var title = _ref2.title,
1295
- value = _ref2.value,
1296
- trend = _ref2.trend,
1297
- detail = _ref2.detail,
1298
- trendPositiveWhenNegative = _ref2.trendPositiveWhenNegative,
1299
- exportMode = _ref2.exportMode;
1300
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1301
- sx: {
1302
- bgcolor: "#fff",
1303
- border: "1px solid #E5E7EB",
1304
- borderRadius: exportMode ? "12px" : "16px",
1305
- p: exportMode ? 1.5 : 2.5,
1306
- boxShadow: "0 4px 24px rgba(0,0,0,0.04)",
1307
- display: "flex",
1308
- flexDirection: "column",
1309
- minHeight: exportMode ? 96 : 130
1310
- },
1311
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1312
- sx: {
1313
- display: "flex",
1314
- justifyContent: "space-between",
1315
- alignItems: "flex-start",
1316
- mb: 0.5
1317
- },
1318
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
943
+ }), actionLabel && /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1319
944
  sx: {
1320
- fontSize: exportMode ? 11 : 13,
1321
- fontWeight: 500,
1322
- color: "#9CA3AF"
945
+ fontSize: compact ? "10px" : "13px",
946
+ fontWeight: 600,
947
+ color: "rgb(99, 99, 230)",
948
+ cursor: "pointer"
1323
949
  },
1324
- children: title
1325
- }), /*#__PURE__*/jsxRuntime.jsx(TrendPill, {
1326
- value: trend,
1327
- trendPositiveWhenNegative: trendPositiveWhenNegative
950
+ children: actionLabel
1328
951
  })]
1329
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1330
- sx: {
1331
- fontSize: exportMode ? 20 : 28,
1332
- fontWeight: 700,
1333
- color: "#111827",
1334
- lineHeight: 1.15,
1335
- mb: exportMode ? 0.75 : 1.5,
1336
- flex: 1
1337
- },
1338
- children: value
1339
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1340
- sx: {
1341
- fontSize: exportMode ? 10 : 12,
1342
- color: "#9CA3AF",
1343
- lineHeight: 1.35
1344
- },
1345
- children: detail
1346
- })]
1347
- });
1348
- };
1349
- var ReportKpiSection = function ReportKpiSection(_ref3) {
1350
- var hero = _ref3.hero,
1351
- metrics = _ref3.metrics,
1352
- _ref3$exportMode = _ref3.exportMode,
1353
- exportMode = _ref3$exportMode === void 0 ? false : _ref3$exportMode;
1354
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1355
- sx: {
1356
- mb: exportMode ? 1.25 : 2
1357
- },
1358
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
952
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1359
953
  sx: {
1360
- bgcolor: "#F7F7FF",
1361
- borderRadius: exportMode ? "12px" : "16px",
1362
- border: "1px solid #E8EAFF",
1363
- borderLeft: "5px solid ".concat(REPORT_COLORS.purple),
1364
- p: exportMode ? 2 : 3,
1365
- mb: exportMode ? 1.25 : 2,
1366
- boxShadow: "0 4px 24px rgba(99,99,230,0.06)"
954
+ overflowX: compact ? "hidden" : "auto"
1367
955
  },
1368
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1369
- sx: {
1370
- fontSize: 11,
1371
- fontWeight: 700,
1372
- letterSpacing: "0.8px",
1373
- color: REPORT_COLORS.purple,
1374
- textTransform: "uppercase",
1375
- mb: 1
1376
- },
1377
- children: "Total Raised"
1378
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
956
+ children: /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1379
957
  sx: {
1380
- display: "flex",
1381
- alignItems: "center",
1382
- flexWrap: "wrap",
1383
- gap: 1.5,
1384
- mb: exportMode ? 0.75 : 1.5
958
+ minWidth: compact ? 0 : "600px"
1385
959
  },
1386
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1387
- sx: {
1388
- fontSize: exportMode ? 30 : {
1389
- xs: 32,
1390
- md: 40
1391
- },
1392
- fontWeight: 800,
1393
- color: "#111827",
1394
- lineHeight: 1
1395
- },
1396
- children: hero.value
1397
- }), /*#__PURE__*/jsxRuntime.jsx(TrendPill, {
1398
- value: hero.trend
1399
- })]
1400
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1401
- sx: {
1402
- fontSize: exportMode ? 11 : 13,
1403
- color: "#9CA3AF"
1404
- },
1405
- children: hero.detail
1406
- })]
1407
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1408
- sx: {
1409
- display: "grid",
1410
- gridTemplateColumns: exportMode ? "repeat(3, 1fr)" : {
1411
- xs: "1fr 1fr",
1412
- md: "repeat(3, 1fr)"
1413
- },
1414
- gap: exportMode ? 1 : 2
1415
- },
1416
- children: metrics.map(function (m) {
1417
- return /*#__PURE__*/jsxRuntime.jsx(MetricCard$1, _objectSpread2(_objectSpread2({}, m), {}, {
1418
- exportMode: exportMode
1419
- }), m.title);
1420
- })
1421
- })]
1422
- });
1423
- };
1424
-
1425
- var ActiveCampaignsCard = function ActiveCampaignsCard(_ref) {
1426
- var _ref$title = _ref.title,
1427
- title = _ref$title === void 0 ? "Active campaigns" : _ref$title,
1428
- _ref$subtitle = _ref.subtitle,
1429
- subtitle = _ref$subtitle === void 0 ? "Live fundraisers ranked by velocity" : _ref$subtitle,
1430
- actionLabel = _ref.actionLabel,
1431
- _ref$columns = _ref.columns,
1432
- columns = _ref$columns === void 0 ? ["Campaign", "Raised", "Progress", "Donors", "Avg gift"] : _ref$columns,
1433
- _ref$rows = _ref.rows,
1434
- rows = _ref$rows === void 0 ? [] : _ref$rows,
1435
- _ref$gridTemplateColu = _ref.gridTemplateColumns,
1436
- gridTemplateColumns = _ref$gridTemplateColu === void 0 ? "3fr 1fr 1.5fr 0.8fr 1fr " : _ref$gridTemplateColu,
1437
- height = _ref.height,
1438
- _ref$compact = _ref.compact,
1439
- compact = _ref$compact === void 0 ? false : _ref$compact;
1440
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1441
- sx: {
1442
- bgcolor: "#fff",
1443
- borderRadius: compact ? 3 : 4,
1444
- border: "1px solid #f0f0f0",
1445
- boxShadow: compact ? "0 2px 12px rgba(0,0,0,0.05)" : "0 4px 24px rgba(0,0,0,0.06)",
1446
- p: compact ? 1.5 : 3,
1447
- height: height
1448
- // height: "100%",
1449
- },
1450
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1451
- sx: {
1452
- display: "flex",
1453
- justifyContent: "space-between",
1454
- alignItems: "flex-start",
1455
- mb: compact ? 1.25 : 3
1456
- },
1457
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1458
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1459
- sx: {
1460
- fontWeight: 700,
1461
- fontSize: compact ? "14px" : "18px",
1462
- color: "#000",
1463
- textAlign: "left"
1464
- },
1465
- children: title
1466
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1467
- sx: {
1468
- fontSize: compact ? "10px" : "13px",
1469
- color: "rgba(0, 0, 0, 0.4)",
1470
- mt: 0.2
1471
- },
1472
- children: subtitle
1473
- })]
1474
- }), actionLabel && /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1475
- sx: {
1476
- fontSize: compact ? "10px" : "13px",
1477
- fontWeight: 600,
1478
- color: "rgb(99, 99, 230)",
1479
- cursor: "pointer"
1480
- },
1481
- children: actionLabel
1482
- })]
1483
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1484
- sx: {
1485
- overflowX: compact ? "hidden" : "auto"
1486
- },
1487
- children: /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1488
- sx: {
1489
- minWidth: compact ? 0 : "600px"
1490
- },
1491
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
960
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
1492
961
  sx: {
1493
962
  display: "grid",
1494
963
  gridTemplateColumns: gridTemplateColumns,
@@ -1681,6 +1150,537 @@ var ActiveCampaignsCard = function ActiveCampaignsCard(_ref) {
1681
1150
  });
1682
1151
  };
1683
1152
 
1153
+ function formatNumber(num) {
1154
+ if (num >= 1000000000) {
1155
+ return (num / 1000000000).toFixed(1).replace(/\.0$/, "") + "B";
1156
+ }
1157
+ if (num >= 1000000) {
1158
+ return (num / 1000000).toFixed(1).replace(/\.0$/, "") + "M";
1159
+ }
1160
+ if (num >= 1000) {
1161
+ return (num / 1000).toFixed(1).replace(/\.0$/, "") + "K";
1162
+ }
1163
+ return (num !== null && num !== void 0 ? num : 0).toString();
1164
+ }
1165
+
1166
+ var PURPLE = "#6363E6";
1167
+ var REPORT_COLORS = {
1168
+ purple: PURPLE};
1169
+ var formatTrend = function formatTrend(value) {
1170
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "percent";
1171
+ var n = Number(value !== null && value !== void 0 ? value : 0);
1172
+ var sign = n >= 0 ? "+" : "";
1173
+ if (type === "pp") return "".concat(sign).concat(n.toFixed(2), "pp");
1174
+ if (type === "x") return "".concat(sign).concat(n.toFixed(1), "x");
1175
+ if (type === "percent") return "".concat(sign).concat(n.toFixed(1), "%");
1176
+ return "".concat(sign).concat(n);
1177
+ };
1178
+ var trendPillSx = function trendPillSx(value) {
1179
+ var n = Number(value !== null && value !== void 0 ? value : 0);
1180
+ var positive = n >= 0;
1181
+ return {
1182
+ display: "inline-flex",
1183
+ alignItems: "center",
1184
+ px: 1.25,
1185
+ py: 0.35,
1186
+ borderRadius: "100px",
1187
+ fontSize: "12px",
1188
+ fontWeight: 600,
1189
+ lineHeight: 1.4,
1190
+ bgcolor: positive ? "#D1FAE5" : "#FEE2E2",
1191
+ color: positive ? "#047857" : "#DC2626",
1192
+ whiteSpace: "nowrap"
1193
+ };
1194
+ };
1195
+ var getActiveFilterChips = function getActiveFilterChips(apiData) {
1196
+ if (Array.isArray(apiData === null || apiData === void 0 ? void 0 : apiData.activeFilterChips) && apiData.activeFilterChips.length) {
1197
+ return apiData.activeFilterChips;
1198
+ }
1199
+ if (typeof (apiData === null || apiData === void 0 ? void 0 : apiData.activeFilters) === "string" && apiData.activeFilters) {
1200
+ return apiData.activeFilters.split("·").map(function (s) {
1201
+ return s.trim();
1202
+ }).filter(Boolean);
1203
+ }
1204
+ return ["Status: Successful", "Country: United States, UAE", "Amount: $50 – $5,000"];
1205
+ };
1206
+ var buildReportData = function buildReportData() {
1207
+ var _apiData$overviewStat, _overview$totalRevenu, _overview$netRevenue, _overview$totalDonati, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _growth$overallAVGDon, _growth$totalRevenue, _growth$netRevenue, _growth$totalDonation, _growth$overallAVGDon2, _apiData$medianGift, _apiData$topDecileGif, _apiData$roasCard, _apiData$roasCardPrev, _apiData$adSpend, _apiData$attributedRe, _growth$conversionRat, _refundsRaw$refundRat, _refundsRaw$refundRat2, _refundsRaw$refundCou, _apiData$overviewStat2, _growth$totalRevenue2;
1208
+ var apiData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1209
+ var dateName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Last Period";
1210
+ var overview = (apiData === null || apiData === void 0 || (_apiData$overviewStat = apiData.overviewStats) === null || _apiData$overviewStat === void 0 ? void 0 : _apiData$overviewStat.overview) || {};
1211
+ var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
1212
+ var refundsRaw = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
1213
+ var totalRaised = Number((_overview$totalRevenu = overview === null || overview === void 0 ? void 0 : overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 240938);
1214
+ var netRaised = Number((_overview$netRevenue = overview === null || overview === void 0 ? void 0 : overview.netRevenue) !== null && _overview$netRevenue !== void 0 ? _overview$netRevenue : 222300);
1215
+ var totalDonors = Number((_overview$totalDonati = overview === null || overview === void 0 ? void 0 : overview.totalDonations) !== null && _overview$totalDonati !== void 0 ? _overview$totalDonati : 215);
1216
+ var avgDonation = Number((_overview$overallAVGD = overview === null || overview === void 0 ? void 0 : overview.overallAVGDonations) !== null && _overview$overallAVGD !== void 0 ? _overview$overallAVGD : 130.58);
1217
+ var convRate = Number((_overview$conversionR = overview === null || overview === void 0 ? void 0 : overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 1.7);
1218
+ var totalVisits = Number((_apiData$totalVisits = apiData === null || apiData === void 0 ? void 0 : apiData.totalVisits) !== null && _apiData$totalVisits !== void 0 ? _apiData$totalVisits : 12438);
1219
+ var passThrough = totalRaised > 0 ? "".concat((netRaised / totalRaised * 100).toFixed(1), "% pass-through") : "92.3% pass-through";
1220
+ var donorMixRaw = apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData;
1221
+ var newDonors = 31;
1222
+ var returningDonors = 184;
1223
+ var avgGift = avgDonation;
1224
+ var donorMixPrev = Number((_growth$overallAVGDon = growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _growth$overallAVGDon !== void 0 ? _growth$overallAVGDon : 8.4);
1225
+ if (Array.isArray(donorMixRaw)) {
1226
+ var nd = donorMixRaw.find(function (d) {
1227
+ return /new/i.test(d.type);
1228
+ }) || {};
1229
+ var rd = donorMixRaw.find(function (d) {
1230
+ return /returning/i.test(d.type);
1231
+ }) || {};
1232
+ newDonors = nd.totalDonations || 0;
1233
+ returningDonors = rd.totalDonations || 0;
1234
+ var totAmt = (nd.totalAmount || 0) + (rd.totalAmount || 0);
1235
+ var totCnt = newDonors + returningDonors;
1236
+ avgGift = totCnt > 0 ? totAmt / totCnt : avgDonation;
1237
+ } else if (donorMixRaw && _typeof(donorMixRaw) === "object") {
1238
+ newDonors = donorMixRaw.newDonors || 0;
1239
+ returningDonors = donorMixRaw.returningDonors || 0;
1240
+ avgGift = donorMixRaw.avgGift || avgDonation;
1241
+ donorMixPrev = donorMixRaw.donorMixPrev || donorMixPrev;
1242
+ }
1243
+ var totalMix = newDonors + returningDonors || 1;
1244
+ var newPct = Math.round(newDonors / totalMix * 100);
1245
+ var retPct = 100 - newPct;
1246
+ var hero = {
1247
+ value: "$".concat(formatNumber(totalRaised)),
1248
+ trend: "".concat(formatTrend((_growth$totalRevenue = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue !== void 0 ? _growth$totalRevenue : 18), " vs ").concat(dateName || "last month"),
1249
+ detail: "".concat(passThrough, " \xB7 ").concat(formatNumber(totalDonors), " donors \xB7 $").concat(formatNumber(avgDonation), " avg \xB7 ").concat(formatNumber(totalVisits), " visits")
1250
+ };
1251
+ var metrics = [{
1252
+ title: "Net Raised",
1253
+ value: "$".concat(formatNumber(netRaised)),
1254
+ trend: formatTrend((_growth$netRevenue = growth === null || growth === void 0 ? void 0 : growth.netRevenue) !== null && _growth$netRevenue !== void 0 ? _growth$netRevenue : 17.4),
1255
+ detail: passThrough
1256
+ }, {
1257
+ title: "Total Donors",
1258
+ value: formatNumber(totalDonors),
1259
+ trend: formatTrend((_growth$totalDonation = growth === null || growth === void 0 ? void 0 : growth.totalDonations) !== null && _growth$totalDonation !== void 0 ? _growth$totalDonation : 16.8),
1260
+ detail: "".concat(formatNumber(newDonors), " new \xB7 ").concat(formatNumber(returningDonors), " returning")
1261
+ }, {
1262
+ title: "Avg Donation",
1263
+ value: "$".concat(formatNumber(avgDonation)),
1264
+ trend: formatTrend((_growth$overallAVGDon2 = growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _growth$overallAVGDon2 !== void 0 ? _growth$overallAVGDon2 : 8.4),
1265
+ detail: "Median $".concat(formatNumber((_apiData$medianGift = apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) !== null && _apiData$medianGift !== void 0 ? _apiData$medianGift : 75), " \xB7 top decile $").concat(formatNumber((_apiData$topDecileGif = apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) !== null && _apiData$topDecileGif !== void 0 ? _apiData$topDecileGif : 850))
1266
+ }, {
1267
+ title: "ROAS",
1268
+ value: "".concat(formatNumber((_apiData$roasCard = apiData === null || apiData === void 0 ? void 0 : apiData.roasCard) !== null && _apiData$roasCard !== void 0 ? _apiData$roasCard : 3.0), "x"),
1269
+ trend: formatTrend((_apiData$roasCardPrev = apiData === null || apiData === void 0 ? void 0 : apiData.roasCardPrev) !== null && _apiData$roasCardPrev !== void 0 ? _apiData$roasCardPrev : 0.4, "x"),
1270
+ detail: "$".concat(formatNumber((_apiData$adSpend = apiData === null || apiData === void 0 ? void 0 : apiData.adSpend) !== null && _apiData$adSpend !== void 0 ? _apiData$adSpend : 72000), " spend \xB7 $").concat(formatNumber((_apiData$attributedRe = apiData === null || apiData === void 0 ? void 0 : apiData.attributedRevenue) !== null && _apiData$attributedRe !== void 0 ? _apiData$attributedRe : 215000), " attrib.")
1271
+ }, {
1272
+ title: "Conversion",
1273
+ value: "".concat(formatNumber(convRate), "%"),
1274
+ trend: formatTrend((_growth$conversionRat = growth === null || growth === void 0 ? void 0 : growth.conversionRate) !== null && _growth$conversionRat !== void 0 ? _growth$conversionRat : 0.21, "pp"),
1275
+ detail: "".concat(formatNumber(totalDonors), " from ").concat(formatNumber(totalVisits), " visits")
1276
+ }, {
1277
+ title: "Refund Rate",
1278
+ value: "".concat(Number((_refundsRaw$refundRat = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRate) !== null && _refundsRaw$refundRat !== void 0 ? _refundsRaw$refundRat : 0.84).toFixed(2), "%"),
1279
+ trend: formatTrend((_refundsRaw$refundRat2 = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange) !== null && _refundsRaw$refundRat2 !== void 0 ? _refundsRaw$refundRat2 : -0.3, "pp"),
1280
+ detail: "".concat(formatNumber((_refundsRaw$refundCou = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundCount) !== null && _refundsRaw$refundCou !== void 0 ? _refundsRaw$refundCou : 2), " refunds this period"),
1281
+ trendPositiveWhenNegative: true
1282
+ }];
1283
+ var stackedTR = (apiData === null || apiData === void 0 || (_apiData$overviewStat2 = apiData.overviewStats) === null || _apiData$overviewStat2 === void 0 ? void 0 : _apiData$overviewStat2.totalRaised) || {};
1284
+ var hasStackedData = (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic);
1285
+ var mainChart = {
1286
+ label: "Total revenue trend",
1287
+ subtitle: "Last 30 days · daily aggregation",
1288
+ value: "$".concat(formatNumber(totalRaised)),
1289
+ trend: "".concat(formatTrend((_growth$totalRevenue2 = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue2 !== void 0 ? _growth$totalRevenue2 : 18), " vs ").concat(dateName || "last month"),
1290
+ hideControls: true,
1291
+ stacked: true,
1292
+ colors: ["#6366F1", "#10B981", "#06B6D4"],
1293
+ stroke: {
1294
+ curve: "smooth",
1295
+ width: 3
1296
+ }
1297
+ };
1298
+ if (hasStackedData) {
1299
+ var categories = ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || []).map(function (item) {
1300
+ return item.date;
1301
+ });
1302
+ mainChart = _objectSpread2(_objectSpread2({}, mainChart), {}, {
1303
+ series: [{
1304
+ name: "Paid Ads",
1305
+ data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || []).map(function (item) {
1306
+ return item.value;
1307
+ })
1308
+ }, {
1309
+ name: "Organic",
1310
+ data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic) || []).map(function (item) {
1311
+ return item.value;
1312
+ })
1313
+ }, {
1314
+ name: "Email",
1315
+ data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || []).map(function (item) {
1316
+ return item.value;
1317
+ })
1318
+ }],
1319
+ categories: categories
1320
+ });
1321
+ } else {
1322
+ var _categories = (apiData === null || apiData === void 0 ? void 0 : apiData.categories) || ["Apr 5", "Apr 11", "Apr 17", "Apr 23", "Apr 29", "May 4"];
1323
+ var base = (apiData === null || apiData === void 0 ? void 0 : apiData.revenueData) || [3000, 4500, 5200, 5800, 6200, 7100, 8500, 9200, 9500];
1324
+ mainChart = _objectSpread2(_objectSpread2({}, mainChart), {}, {
1325
+ series: [{
1326
+ name: "Paid Ads",
1327
+ data: base.map(function (v) {
1328
+ return v * 0.55;
1329
+ })
1330
+ }, {
1331
+ name: "Organic",
1332
+ data: base.map(function (v) {
1333
+ return v * 0.28;
1334
+ })
1335
+ }, {
1336
+ name: "Email",
1337
+ data: base.map(function (v) {
1338
+ return v * 0.17;
1339
+ })
1340
+ }],
1341
+ categories: _categories
1342
+ });
1343
+ }
1344
+ var sampleCampaigns = [{
1345
+ title: "Orphan sponsorship — Yemen",
1346
+ collectedAmount: 78400,
1347
+ usdTargetAmount: 100000,
1348
+ uniqueDonationsCount: 82,
1349
+ status: "Active"
1350
+ }, {
1351
+ title: "Emergency food — Gaza",
1352
+ collectedAmount: 62100,
1353
+ usdTargetAmount: 75000,
1354
+ uniqueDonationsCount: 61,
1355
+ status: "Active"
1356
+ }, {
1357
+ title: "Masjid build — Somalia",
1358
+ collectedAmount: 38200,
1359
+ usdTargetAmount: 83000,
1360
+ uniqueDonationsCount: 34,
1361
+ status: "Slow"
1362
+ }, {
1363
+ title: "Water wells — Pakistan",
1364
+ collectedAmount: 29800,
1365
+ usdTargetAmount: 30000,
1366
+ uniqueDonationsCount: 28,
1367
+ status: "Closing"
1368
+ }, {
1369
+ title: "Ramadan packs — Egypt",
1370
+ collectedAmount: 18400,
1371
+ usdTargetAmount: 23500,
1372
+ uniqueDonationsCount: 10,
1373
+ status: "Active"
1374
+ }];
1375
+ var campaignSource = ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).length ? apiData.activeCampaigns : sampleCampaigns;
1376
+ var activeCampaigns = campaignSource.map(function (campaign) {
1377
+ return {
1378
+ id: campaign.campaignName ? campaign.campaignName.split(" ").filter(Boolean).map(function (w) {
1379
+ return w[0];
1380
+ }).join("").toUpperCase().slice(0, 2) : "??",
1381
+ name: campaign.title || "Untitled Campaign",
1382
+ val1: "$".concat(formatNumber(campaign.collectedAmount || 0)),
1383
+ type: "progress",
1384
+ progress: Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100),
1385
+ val3: formatNumber(campaign.uniqueDonationsCount || 0),
1386
+ val4: "$".concat(formatNumber(campaign.avgGift || 0))
1387
+ };
1388
+ });
1389
+ return {
1390
+ hero: hero,
1391
+ metrics: metrics,
1392
+ mainChart: mainChart,
1393
+ growth: growth,
1394
+ totalDonors: totalDonors,
1395
+ donorMix: {
1396
+ newDonors: newDonors,
1397
+ returningDonors: returningDonors,
1398
+ totalMix: totalMix,
1399
+ newPct: newPct,
1400
+ retPct: retPct,
1401
+ avgGift: avgGift,
1402
+ donorMixPrev: donorMixPrev
1403
+ },
1404
+ activeCampaigns: activeCampaigns,
1405
+ donationTypeData: (apiData === null || apiData === void 0 ? void 0 : apiData.recurringBarChartData) || [],
1406
+ donorGeographyData: (apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography) || [],
1407
+ trafficSourceData: (apiData === null || apiData === void 0 ? void 0 : apiData.trafficSourceData) || [],
1408
+ orderBumpData: (apiData === null || apiData === void 0 ? void 0 : apiData.orderBumpDetails) || [],
1409
+ upsellData: (apiData === null || apiData === void 0 ? void 0 : apiData.upSellDetails) || {},
1410
+ downsellData: (apiData === null || apiData === void 0 ? void 0 : apiData.downSellDetails) || {},
1411
+ referralData: (apiData === null || apiData === void 0 ? void 0 : apiData.referralDetails) || {},
1412
+ refundsChargebacksData: (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || []
1413
+ };
1414
+ };
1415
+
1416
+ var ReportHeader = function ReportHeader(_ref) {
1417
+ var dateName = _ref.dateName,
1418
+ _ref$activeFilterChip = _ref.activeFilterChips,
1419
+ activeFilterChips = _ref$activeFilterChip === void 0 ? [] : _ref$activeFilterChip,
1420
+ _ref$exportMode = _ref.exportMode,
1421
+ exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode;
1422
+ var now = new Date();
1423
+ var generatedLabel = now.toLocaleDateString("en-US", {
1424
+ month: "short",
1425
+ day: "numeric",
1426
+ year: "numeric"
1427
+ }) + " · " + now.toLocaleTimeString("en-US", {
1428
+ hour: "2-digit",
1429
+ minute: "2-digit"
1430
+ }) + " GMT";
1431
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1432
+ sx: {
1433
+ mb: exportMode ? 1.5 : 3
1434
+ },
1435
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1436
+ sx: {
1437
+ display: "flex",
1438
+ justifyContent: "space-between",
1439
+ alignItems: "flex-start",
1440
+ flexWrap: "wrap",
1441
+ gap: exportMode ? 1 : 2,
1442
+ mb: exportMode ? 1.25 : 2.5
1443
+ },
1444
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1445
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1446
+ sx: {
1447
+ fontSize: exportMode ? 26 : {
1448
+ xs: 28,
1449
+ md: 32
1450
+ },
1451
+ fontWeight: 800,
1452
+ color: REPORT_COLORS.purple,
1453
+ letterSpacing: "-0.5px",
1454
+ lineHeight: 1.1
1455
+ },
1456
+ children: "MaDinah"
1457
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1458
+ sx: {
1459
+ fontSize: 11,
1460
+ fontWeight: 700,
1461
+ letterSpacing: "1.6px",
1462
+ color: "#9CA3AF",
1463
+ textTransform: "uppercase",
1464
+ mt: 0.5
1465
+ },
1466
+ children: "Performance Report"
1467
+ })]
1468
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1469
+ sx: {
1470
+ textAlign: {
1471
+ xs: "left",
1472
+ sm: "right"
1473
+ }
1474
+ },
1475
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1476
+ sx: {
1477
+ fontSize: 14,
1478
+ color: "#6B7280",
1479
+ mb: 0.5
1480
+ },
1481
+ children: "Dashboard overview \u2014 Overall"
1482
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1483
+ sx: {
1484
+ fontSize: exportMode ? 16 : {
1485
+ xs: 18,
1486
+ md: 20
1487
+ },
1488
+ fontWeight: 700,
1489
+ color: "#111827",
1490
+ mb: 0.5
1491
+ },
1492
+ children: dateName
1493
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
1494
+ sx: {
1495
+ fontSize: exportMode ? 10 : 12,
1496
+ color: "#9CA3AF"
1497
+ },
1498
+ children: ["30-day window \xB7 Generated ", generatedLabel]
1499
+ })]
1500
+ })]
1501
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1502
+ sx: {
1503
+ display: "flex",
1504
+ alignItems: "center",
1505
+ flexWrap: "wrap",
1506
+ gap: 1.25,
1507
+ bgcolor: "#F3F4F6",
1508
+ borderRadius: "12px",
1509
+ px: 2,
1510
+ py: 1.25
1511
+ },
1512
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1513
+ sx: {
1514
+ fontSize: 11,
1515
+ fontWeight: 700,
1516
+ letterSpacing: "0.6px",
1517
+ color: "#6B7280",
1518
+ textTransform: "uppercase",
1519
+ mr: 0.5
1520
+ },
1521
+ children: "Active Filters"
1522
+ }), activeFilterChips.map(function (chip) {
1523
+ return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1524
+ sx: {
1525
+ px: 1.5,
1526
+ py: 0.5,
1527
+ borderRadius: "100px",
1528
+ border: "1px solid ".concat(REPORT_COLORS.purple),
1529
+ bgcolor: "#fff",
1530
+ fontSize: 12,
1531
+ fontWeight: 500,
1532
+ color: REPORT_COLORS.purple
1533
+ },
1534
+ children: chip
1535
+ }, chip);
1536
+ })]
1537
+ })]
1538
+ });
1539
+ };
1540
+
1541
+ var TrendPill = function TrendPill(_ref) {
1542
+ var value = _ref.value,
1543
+ _ref$trendPositiveWhe = _ref.trendPositiveWhenNegative,
1544
+ trendPositiveWhenNegative = _ref$trendPositiveWhe === void 0 ? false : _ref$trendPositiveWhe;
1545
+ var n = Number(String(value).replace(/[^0-9.-]/g, "") || 0);
1546
+ var positive = trendPositiveWhenNegative ? n <= 0 : n >= 0;
1547
+ return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1548
+ sx: _objectSpread2({}, trendPillSx(positive ? 1 : -1)),
1549
+ children: value
1550
+ });
1551
+ };
1552
+ var MetricCard$1 = function MetricCard(_ref2) {
1553
+ var title = _ref2.title,
1554
+ value = _ref2.value,
1555
+ trend = _ref2.trend,
1556
+ detail = _ref2.detail,
1557
+ trendPositiveWhenNegative = _ref2.trendPositiveWhenNegative,
1558
+ exportMode = _ref2.exportMode;
1559
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1560
+ sx: {
1561
+ bgcolor: "#fff",
1562
+ border: "1px solid #E5E7EB",
1563
+ borderRadius: exportMode ? "12px" : "16px",
1564
+ p: exportMode ? 1.5 : 2.5,
1565
+ boxShadow: "0 4px 24px rgba(0,0,0,0.04)",
1566
+ display: "flex",
1567
+ flexDirection: "column",
1568
+ minHeight: exportMode ? 96 : 130
1569
+ },
1570
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1571
+ sx: {
1572
+ display: "flex",
1573
+ justifyContent: "space-between",
1574
+ alignItems: "flex-start",
1575
+ mb: 0.5
1576
+ },
1577
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1578
+ sx: {
1579
+ fontSize: exportMode ? 11 : 13,
1580
+ fontWeight: 500,
1581
+ color: "#9CA3AF"
1582
+ },
1583
+ children: title
1584
+ }), /*#__PURE__*/jsxRuntime.jsx(TrendPill, {
1585
+ value: trend,
1586
+ trendPositiveWhenNegative: trendPositiveWhenNegative
1587
+ })]
1588
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1589
+ sx: {
1590
+ fontSize: exportMode ? 20 : 28,
1591
+ fontWeight: 700,
1592
+ color: "#111827",
1593
+ lineHeight: 1.15,
1594
+ mb: exportMode ? 0.75 : 1.5,
1595
+ flex: 1
1596
+ },
1597
+ children: value
1598
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1599
+ sx: {
1600
+ fontSize: exportMode ? 10 : 12,
1601
+ color: "#9CA3AF",
1602
+ lineHeight: 1.35
1603
+ },
1604
+ children: detail
1605
+ })]
1606
+ });
1607
+ };
1608
+ var ReportKpiSection = function ReportKpiSection(_ref3) {
1609
+ var hero = _ref3.hero,
1610
+ metrics = _ref3.metrics,
1611
+ _ref3$exportMode = _ref3.exportMode,
1612
+ exportMode = _ref3$exportMode === void 0 ? false : _ref3$exportMode;
1613
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1614
+ sx: {
1615
+ mb: exportMode ? 1.25 : 2
1616
+ },
1617
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1618
+ sx: {
1619
+ bgcolor: "#F7F7FF",
1620
+ borderRadius: exportMode ? "12px" : "16px",
1621
+ border: "1px solid #E8EAFF",
1622
+ borderLeft: "5px solid ".concat(REPORT_COLORS.purple),
1623
+ p: exportMode ? 2 : 3,
1624
+ mb: exportMode ? 1.25 : 2,
1625
+ boxShadow: "0 4px 24px rgba(99,99,230,0.06)"
1626
+ },
1627
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1628
+ sx: {
1629
+ fontSize: 11,
1630
+ fontWeight: 700,
1631
+ letterSpacing: "0.8px",
1632
+ color: REPORT_COLORS.purple,
1633
+ textTransform: "uppercase",
1634
+ mb: 1
1635
+ },
1636
+ children: "Total Raised"
1637
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1638
+ sx: {
1639
+ display: "flex",
1640
+ alignItems: "center",
1641
+ flexWrap: "wrap",
1642
+ gap: 1.5,
1643
+ mb: exportMode ? 0.75 : 1.5
1644
+ },
1645
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1646
+ sx: {
1647
+ fontSize: exportMode ? 30 : {
1648
+ xs: 32,
1649
+ md: 40
1650
+ },
1651
+ fontWeight: 800,
1652
+ color: "#111827",
1653
+ lineHeight: 1
1654
+ },
1655
+ children: hero.value
1656
+ }), /*#__PURE__*/jsxRuntime.jsx(TrendPill, {
1657
+ value: hero.trend
1658
+ })]
1659
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1660
+ sx: {
1661
+ fontSize: exportMode ? 11 : 13,
1662
+ color: "#9CA3AF"
1663
+ },
1664
+ children: hero.detail
1665
+ })]
1666
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1667
+ sx: {
1668
+ display: "grid",
1669
+ gridTemplateColumns: exportMode ? "repeat(3, 1fr)" : {
1670
+ xs: "1fr 1fr",
1671
+ md: "repeat(3, 1fr)"
1672
+ },
1673
+ gap: exportMode ? 1 : 2
1674
+ },
1675
+ children: metrics.map(function (m) {
1676
+ return /*#__PURE__*/jsxRuntime.jsx(MetricCard$1, _objectSpread2(_objectSpread2({}, m), {}, {
1677
+ exportMode: exportMode
1678
+ }), m.title);
1679
+ })
1680
+ })]
1681
+ });
1682
+ };
1683
+
1684
1684
  var DonorMixCard = function DonorMixCard(_ref) {
1685
1685
  var _ref$title = _ref.title,
1686
1686
  title = _ref$title === void 0 ? "Donor mix" : _ref$title,
@@ -4146,7 +4146,8 @@ var fourColGridSx = function fourColGridSx(exportMode) {
4146
4146
  gridTemplateColumns: exportMode ? "repeat(4, 1fr)" : {
4147
4147
  xs: "1fr",
4148
4148
  sm: "repeat(2, 1fr)",
4149
- md: "repeat(4, 1fr)"
4149
+ md: "repeat(3, 1fr)",
4150
+ xl: "repeat(4, 1fr)"
4150
4151
  },
4151
4152
  gap: GRID_GAP,
4152
4153
  mt: GRID_GAP,
@@ -16484,6 +16485,7 @@ var EmailSection$1 = /*#__PURE__*/Object.freeze({
16484
16485
  });
16485
16486
 
16486
16487
  exports.AbandonedDonationRecovery = AbandonedDonationRecovery;
16488
+ exports.ActiveCampaignsCard = ActiveCampaignsCard;
16487
16489
  exports.Dashboard = Dashboard;
16488
16490
  exports.DashboardReport = DashboardReport;
16489
16491
  exports.DashboardTheme = theme;
@@ -16492,6 +16494,7 @@ exports.MetricSelector = MetricSelector;
16492
16494
  exports.NewOverview = NewOverview;
16493
16495
  exports.PerformanceSection = PerformanceSection;
16494
16496
  exports.RecurringRevenueSection = RecurringRevenueSection;
16497
+ exports.RenderChartCard = RenderChartCard;
16495
16498
  exports.RevenueChart = RevenueChart;
16496
16499
  exports.UTMPerformance = UTMPerformance;
16497
16500
  exports.themeColors = themeColors;