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