@ammarkhalidfarooq/dashboard-package 0.5.37 → 0.5.38

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
@@ -595,7 +595,7 @@ var RenderChartCard = function RenderChartCard(_ref) {
595
595
  },
596
596
  children: /*#__PURE__*/jsxRuntime.jsxs(material.CardContent, {
597
597
  sx: {
598
- p: 3,
598
+ p: item.exportMode ? 2 : 3,
599
599
  flexGrow: 1,
600
600
  display: "flex",
601
601
  flexDirection: "column"
@@ -605,7 +605,7 @@ var RenderChartCard = function RenderChartCard(_ref) {
605
605
  display: "flex",
606
606
  justifyContent: "space-between",
607
607
  alignItems: "flex-start",
608
- mb: isPremium ? 3 : 2
608
+ mb: item.exportMode ? 2 : isPremium ? 3 : 2
609
609
  },
610
610
  children: [isPremium ? /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
611
611
  sx: {
@@ -697,7 +697,7 @@ var RenderChartCard = function RenderChartCard(_ref) {
697
697
  },
698
698
  children: item.hideControls ? item.series && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
699
699
  sx: {
700
- display: {
700
+ display: item.exportMode ? "flex" : {
701
701
  xs: "none",
702
702
  sm: "flex"
703
703
  },
@@ -902,8 +902,6 @@ function formatNumber(num) {
902
902
  }
903
903
 
904
904
  var PURPLE = "#6363E6";
905
- var GREEN = "#10B981";
906
- var BLUE = "#06B6D4";
907
905
  var REPORT_COLORS = {
908
906
  purple: PURPLE};
909
907
  var formatTrend = function formatTrend(value) {
@@ -1029,7 +1027,7 @@ var buildReportData = function buildReportData() {
1029
1027
  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"),
1030
1028
  hideControls: true,
1031
1029
  stacked: true,
1032
- colors: [PURPLE, GREEN, BLUE],
1030
+ colors: ["#6366F1", "#10B981", "#06B6D4"],
1033
1031
  stroke: {
1034
1032
  curve: "smooth",
1035
1033
  width: 3
@@ -1081,37 +1079,6 @@ var buildReportData = function buildReportData() {
1081
1079
  categories: _categories
1082
1080
  });
1083
1081
  }
1084
- var campaignStatus = function campaignStatus(campaign) {
1085
- if (campaign.status) return campaign.status;
1086
- var progress = Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100);
1087
- if (progress >= 95) return "Closing";
1088
- if (progress < 50) return "Slow";
1089
- return "Active";
1090
- };
1091
- var statusStyle = function statusStyle(status) {
1092
- switch (status) {
1093
- case "Slow":
1094
- return {
1095
- statusBg: "#FEF3C7",
1096
- statusColor: "#B45309"
1097
- };
1098
- case "Closing":
1099
- return {
1100
- statusBg: "#DBEAFE",
1101
- statusColor: "#1D4ED8"
1102
- };
1103
- default:
1104
- return {
1105
- statusBg: "#D1FAE5",
1106
- statusColor: "#047857"
1107
- };
1108
- }
1109
- };
1110
- var progressColor = function progressColor(progress) {
1111
- if (progress >= 95) return GREEN;
1112
- if (progress < 50) return "#F59E0B";
1113
- return PURPLE;
1114
- };
1115
1082
  var sampleCampaigns = [{
1116
1083
  title: "Orphan sponsorship — Yemen",
1117
1084
  collectedAmount: 78400,
@@ -1145,20 +1112,17 @@ var buildReportData = function buildReportData() {
1145
1112
  }];
1146
1113
  var campaignSource = ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).length ? apiData.activeCampaigns : sampleCampaigns;
1147
1114
  var activeCampaigns = campaignSource.map(function (campaign) {
1148
- var progress = Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100);
1149
- var status = campaignStatus(campaign);
1150
- return _objectSpread2({
1115
+ return {
1151
1116
  id: campaign.campaignName ? campaign.campaignName.split(" ").filter(Boolean).map(function (w) {
1152
1117
  return w[0];
1153
1118
  }).join("").toUpperCase().slice(0, 2) : "??",
1154
1119
  name: campaign.title || "Untitled Campaign",
1155
1120
  val1: "$".concat(formatNumber(campaign.collectedAmount || 0)),
1156
1121
  type: "progress",
1157
- progress: progress,
1158
- progressColor: progressColor(progress),
1122
+ progress: Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100),
1159
1123
  val3: formatNumber(campaign.uniqueDonationsCount || 0),
1160
- status: status
1161
- }, statusStyle(status));
1124
+ val4: "$".concat(formatNumber(campaign.avgGift || 0))
1125
+ };
1162
1126
  });
1163
1127
  return {
1164
1128
  hero: hero,
@@ -4142,115 +4106,173 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
4142
4106
  });
4143
4107
  };
4144
4108
 
4145
- var cardHeight = function cardHeight(exportMode) {
4146
- return exportMode ? 158 : 300;
4109
+ var CARD_SX = {
4110
+ maxHeight: 280
4147
4111
  };
4148
- var ReportDetailsSection = function ReportDetailsSection(_ref) {
4149
- var _orderBumpData$chart, _orderBumpData$peakDa, _referralData$chartDa;
4150
- var reportData = _ref.reportData,
4151
- dateName = _ref.dateName,
4152
- _ref$exportMode = _ref.exportMode,
4153
- exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode,
4154
- _ref$section = _ref.section,
4155
- section = _ref$section === void 0 ? "all" : _ref$section;
4156
- var activeCampaigns = reportData.activeCampaigns,
4157
- donorMix = reportData.donorMix,
4158
- donationTypeData = reportData.donationTypeData,
4159
- donorGeographyData = reportData.donorGeographyData,
4160
- trafficSourceData = reportData.trafficSourceData,
4161
- orderBumpData = reportData.orderBumpData,
4162
- upsellData = reportData.upsellData,
4163
- downsellData = reportData.downsellData,
4164
- referralData = reportData.referralData,
4165
- refundsChargebacksData = reportData.refundsChargebacksData;
4166
- var gridSx = {
4112
+ var GRID_GAP = "6px";
4113
+ var fourColGridSx = function fourColGridSx(exportMode) {
4114
+ return {
4167
4115
  display: "grid",
4168
4116
  gridTemplateColumns: exportMode ? "repeat(4, 1fr)" : {
4169
4117
  xs: "1fr",
4170
- sm: "1fr 1fr",
4171
- lg: "repeat(4, 1fr)"
4118
+ sm: "repeat(2, 1fr)",
4119
+ md: "repeat(4, 1fr)"
4172
4120
  },
4173
- gap: exportMode ? 0.75 : 2
4174
- };
4175
- var cardSx = {
4176
- maxHeight: cardHeight(exportMode),
4177
- minHeight: exportMode ? cardHeight(exportMode) : undefined
4121
+ gap: GRID_GAP,
4122
+ mt: GRID_GAP,
4123
+ alignItems: "stretch"
4178
4124
  };
4179
- var campaignsRow = /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4125
+ };
4126
+ var OverallDetailsGrid = function OverallDetailsGrid(_ref) {
4127
+ var _orderBumpData$chart, _orderBumpData$peakDa, _orderBumpData$peakDa2, _referralData$chartDa;
4128
+ var _ref$exportMode = _ref.exportMode,
4129
+ exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode,
4130
+ _ref$section = _ref.section,
4131
+ section = _ref$section === void 0 ? "all" : _ref$section,
4132
+ _ref$activeCampaignsR = _ref.activeCampaignsRows,
4133
+ activeCampaignsRows = _ref$activeCampaignsR === void 0 ? [] : _ref$activeCampaignsR,
4134
+ _ref$donorMix = _ref.donorMix,
4135
+ donorMix = _ref$donorMix === void 0 ? {} : _ref$donorMix,
4136
+ _ref$donationTypeData = _ref.donationTypeData,
4137
+ donationTypeData = _ref$donationTypeData === void 0 ? [] : _ref$donationTypeData,
4138
+ _ref$donorGeographyDa = _ref.donorGeographyData,
4139
+ donorGeographyData = _ref$donorGeographyDa === void 0 ? [] : _ref$donorGeographyDa,
4140
+ _ref$trafficSourceDat = _ref.trafficSourceData,
4141
+ trafficSourceData = _ref$trafficSourceDat === void 0 ? {} : _ref$trafficSourceDat,
4142
+ _ref$orderBumpData = _ref.orderBumpData,
4143
+ orderBumpData = _ref$orderBumpData === void 0 ? {} : _ref$orderBumpData,
4144
+ _ref$upsellData = _ref.upsellData,
4145
+ upsellData = _ref$upsellData === void 0 ? {} : _ref$upsellData,
4146
+ _ref$downsellData = _ref.downsellData,
4147
+ downsellData = _ref$downsellData === void 0 ? {} : _ref$downsellData,
4148
+ _ref$referralData = _ref.referralData,
4149
+ referralData = _ref$referralData === void 0 ? {} : _ref$referralData,
4150
+ _ref$refundsChargebac = _ref.refundsChargebacksData,
4151
+ refundsChargebacksData = _ref$refundsChargebac === void 0 ? [] : _ref$refundsChargebac,
4152
+ _ref$dateName = _ref.dateName,
4153
+ dateName = _ref$dateName === void 0 ? "Last Period" : _ref$dateName;
4154
+ var _donorMix$newDonors = donorMix.newDonors,
4155
+ newDonors = _donorMix$newDonors === void 0 ? 0 : _donorMix$newDonors,
4156
+ _donorMix$returningDo = donorMix.returningDonors,
4157
+ returningDonors = _donorMix$returningDo === void 0 ? 0 : _donorMix$returningDo,
4158
+ _donorMix$totalMix = donorMix.totalMix,
4159
+ totalMix = _donorMix$totalMix === void 0 ? 0 : _donorMix$totalMix,
4160
+ _donorMix$newPct = donorMix.newPct,
4161
+ newPct = _donorMix$newPct === void 0 ? 0 : _donorMix$newPct,
4162
+ _donorMix$retPct = donorMix.retPct,
4163
+ retPct = _donorMix$retPct === void 0 ? 0 : _donorMix$retPct,
4164
+ _donorMix$avgGift = donorMix.avgGift,
4165
+ avgGift = _donorMix$avgGift === void 0 ? 0 : _donorMix$avgGift,
4166
+ _donorMix$donorMixPre = donorMix.donorMixPrev,
4167
+ donorMixPrev = _donorMix$donorMixPre === void 0 ? 0 : _donorMix$donorMixPre;
4168
+ var campaignsRow = exportMode ? /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4180
4169
  sx: {
4181
4170
  display: "grid",
4182
- gridTemplateColumns: exportMode ? "1fr 200px" : {
4183
- xs: "1fr",
4184
- lg: "2.25fr 1fr"
4185
- },
4186
- gap: exportMode ? 0.75 : 2,
4187
- mb: exportMode ? 0.75 : 2,
4171
+ gridTemplateColumns: "2.25fr 1fr",
4172
+ gap: GRID_GAP,
4188
4173
  alignItems: "stretch"
4189
4174
  },
4190
4175
  children: [/*#__PURE__*/jsxRuntime.jsx(ActiveCampaignsCard, {
4191
4176
  title: "Active campaigns",
4192
4177
  subtitle: "Live fundraisers ranked by velocity",
4193
- actionLabel: exportMode ? undefined : "View all",
4194
- columns: ["Campaign", "Raised", "Progress", "Donors", "Status"],
4195
- gridTemplateColumns: "2.2fr 0.9fr 1.3fr 0.6fr 0.8fr",
4196
- rows: activeCampaigns,
4197
- compact: exportMode
4178
+ columns: ["Campaign", "Raised", "Progress", "Donors", "Avg gift"],
4179
+ rows: activeCampaignsRows
4198
4180
  }), /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
4199
4181
  title: "Donor mix",
4200
4182
  subtitle: "Acquisition vs retention",
4201
- series: [donorMix.newDonors, donorMix.returningDonors],
4183
+ series: [newDonors, returningDonors],
4202
4184
  labels: ["New donors", "Returning"],
4203
- colors: ["#10B981", "rgb(99, 99, 230)"],
4185
+ colors: ["rgb(99, 99, 230)", "#10B981"],
4204
4186
  centerLabel: "donors",
4205
- centerValue: String(donorMix.totalMix),
4187
+ centerValue: String(totalMix),
4206
4188
  items: [{
4207
4189
  label: "New donors",
4208
- val: "".concat(donorMix.newDonors, " \xB7 ").concat(donorMix.newPct, "%"),
4209
- color: "#10B981"
4190
+ val: "".concat(newDonors, " \xB7 ").concat(newPct, "%"),
4191
+ color: "rgb(99, 99, 230)"
4210
4192
  }, {
4211
4193
  label: "Returning",
4212
- val: "".concat(donorMix.returningDonors, " \xB7 ").concat(donorMix.retPct, "%"),
4213
- color: "rgb(99, 99, 230)"
4194
+ val: "".concat(returningDonors, " \xB7 ").concat(retPct, "%"),
4195
+ color: "#10B981"
4214
4196
  }],
4215
- bottomSummaryValue: "$".concat(formatNumber(donorMix.avgGift)),
4216
- bottomSummaryTrend: "".concat(donorMix.donorMixPrev, "% vs ").concat(dateName || "last month"),
4217
- compact: exportMode,
4197
+ bottomSummaryValue: "$".concat(avgGift),
4198
+ bottomSummaryTrend: "".concat(donorMixPrev, "% vs ").concat(dateName || "last month"),
4218
4199
  sx: {
4219
- height: "100%"
4200
+ width: "100%"
4220
4201
  }
4221
4202
  })]
4203
+ }) : /*#__PURE__*/jsxRuntime.jsxs(material.Grid, {
4204
+ container: true,
4205
+ spacing: GRID_GAP,
4206
+ sx: {
4207
+ mt: GRID_GAP
4208
+ },
4209
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Grid, {
4210
+ item: true,
4211
+ xs: 12,
4212
+ md: 9,
4213
+ sx: {
4214
+ paddingTop: "0px !important"
4215
+ },
4216
+ children: /*#__PURE__*/jsxRuntime.jsx(ActiveCampaignsCard, {
4217
+ title: "Active campaigns",
4218
+ subtitle: "Live fundraisers ranked by velocity",
4219
+ columns: ["Campaign", "Raised", "Progress", "Donors", "Avg gift"],
4220
+ rows: activeCampaignsRows
4221
+ })
4222
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
4223
+ item: true,
4224
+ xs: 12,
4225
+ md: 3,
4226
+ sx: {
4227
+ display: "flex",
4228
+ paddingTop: "0px !important",
4229
+ marginTop: {
4230
+ xs: GRID_GAP,
4231
+ md: 0
4232
+ }
4233
+ },
4234
+ children: /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
4235
+ title: "Donor mix",
4236
+ subtitle: "Acquisition vs retention",
4237
+ series: [newDonors, returningDonors],
4238
+ labels: ["New donors", "Returning"],
4239
+ colors: ["rgb(99, 99, 230)", "#10B981"],
4240
+ centerLabel: "donors",
4241
+ centerValue: String(totalMix),
4242
+ items: [{
4243
+ label: "New donors",
4244
+ val: "".concat(newDonors, " \xB7 ").concat(newPct, "%"),
4245
+ color: "rgb(99, 99, 230)"
4246
+ }, {
4247
+ label: "Returning",
4248
+ val: "".concat(returningDonors, " \xB7 ").concat(retPct, "%"),
4249
+ color: "#10B981"
4250
+ }],
4251
+ bottomSummaryValue: "$".concat(avgGift),
4252
+ bottomSummaryTrend: "".concat(donorMixPrev, "% vs ").concat(dateName || "last month"),
4253
+ sx: {
4254
+ width: "100%"
4255
+ }
4256
+ })
4257
+ })]
4222
4258
  });
4223
- var middleCards = /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4224
- sx: gridSx,
4259
+ var middleCards = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4225
4260
  children: [/*#__PURE__*/jsxRuntime.jsx(DonationTypeBarChart, {
4226
- sx: _objectSpread2(_objectSpread2({}, cardSx), exportMode && {
4227
- p: 1.25,
4228
- borderRadius: 3
4229
- }),
4261
+ sx: CARD_SX,
4230
4262
  donationTypeData: donationTypeData
4231
4263
  }), /*#__PURE__*/jsxRuntime.jsx(PaidDonorGeographyCard, {
4232
- sx: _objectSpread2(_objectSpread2({}, cardSx), exportMode && {
4233
- p: 1.25,
4234
- borderRadius: 3
4235
- }),
4264
+ sx: CARD_SX,
4236
4265
  donorGeographyData: donorGeographyData
4237
4266
  }), /*#__PURE__*/jsxRuntime.jsx(RefundsChargebacksCard, {
4238
- sx: _objectSpread2(_objectSpread2({}, cardSx), exportMode && {
4239
- p: 1.25,
4240
- borderRadius: 3
4241
- }),
4267
+ sx: CARD_SX,
4242
4268
  refundsChargebacksData: refundsChargebacksData
4243
4269
  }), /*#__PURE__*/jsxRuntime.jsx(TrafficSourceCard, {
4244
- sx: _objectSpread2(_objectSpread2({}, cardSx), exportMode && {
4245
- p: 1.25,
4246
- borderRadius: 3
4247
- }),
4270
+ sx: CARD_SX,
4248
4271
  trafficSourceData: (trafficSourceData === null || trafficSourceData === void 0 ? void 0 : trafficSourceData.data) || [],
4249
4272
  total: "$".concat(formatNumber((trafficSourceData === null || trafficSourceData === void 0 ? void 0 : trafficSourceData.totalRevenue) || 0))
4250
4273
  })]
4251
4274
  });
4252
- var bottomCards = /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4253
- sx: gridSx,
4275
+ var bottomCards = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4254
4276
  children: [/*#__PURE__*/jsxRuntime.jsx(MetricSparklineCard, {
4255
4277
  title: "Order Bump",
4256
4278
  subtitle: "Revenue trend \xB7 last 30 days",
@@ -4263,18 +4285,18 @@ var ReportDetailsSection = function ReportDetailsSection(_ref) {
4263
4285
  };
4264
4286
  })) || [],
4265
4287
  footerMetrics: [{
4266
- label: "Avg/day",
4288
+ label: "Avg / Day",
4267
4289
  value: "$".concat(formatNumber((orderBumpData === null || orderBumpData === void 0 ? void 0 : orderBumpData.averagePerDay) || 0))
4268
- }, {
4269
- label: "Peak day",
4270
- value: "$".concat(formatNumber((orderBumpData === null || orderBumpData === void 0 || (_orderBumpData$peakDa = orderBumpData.peakDay) === null || _orderBumpData$peakDa === void 0 ? void 0 : _orderBumpData$peakDa.amount) || 0))
4271
4290
  }, {
4272
4291
  label: "Orders",
4273
4292
  value: formatNumber((orderBumpData === null || orderBumpData === void 0 ? void 0 : orderBumpData.totalOrders) || 0)
4293
+ }, {
4294
+ label: "Peak Day",
4295
+ value: "$".concat(formatNumber((orderBumpData === null || orderBumpData === void 0 || (_orderBumpData$peakDa = orderBumpData.peakDay) === null || _orderBumpData$peakDa === void 0 ? void 0 : _orderBumpData$peakDa.amount) || 0)),
4296
+ subValue: orderBumpData === null || orderBumpData === void 0 || (_orderBumpData$peakDa2 = orderBumpData.peakDay) === null || _orderBumpData$peakDa2 === void 0 ? void 0 : _orderBumpData$peakDa2.date
4274
4297
  }],
4275
- sx: cardSx,
4276
- bottomSection: true,
4277
- compact: exportMode
4298
+ sx: CARD_SX,
4299
+ bottomSection: true
4278
4300
  }), /*#__PURE__*/jsxRuntime.jsx(MetricDonutCard, {
4279
4301
  title: "Upsell",
4280
4302
  subtitle: "Acceptance & raised",
@@ -4283,8 +4305,7 @@ var ReportDetailsSection = function ReportDetailsSection(_ref) {
4283
4305
  acceptanceTrend: "".concat((upsellData === null || upsellData === void 0 ? void 0 : upsellData.acceptanceGrowth) >= 0 ? "▲" : "▼", " ").concat(Math.abs((upsellData === null || upsellData === void 0 ? void 0 : upsellData.acceptanceGrowth) || 0).toFixed(1), "%"),
4284
4306
  raisedVal: "$".concat(formatNumber((upsellData === null || upsellData === void 0 ? void 0 : upsellData.raised) || 0)),
4285
4307
  raisedTrend: "".concat((upsellData === null || upsellData === void 0 ? void 0 : upsellData.raisedGrowth) >= 0 ? "▲" : "▼", " ").concat(Math.abs((upsellData === null || upsellData === void 0 ? void 0 : upsellData.raisedGrowth) || 0).toFixed(1), "%"),
4286
- sx: cardSx,
4287
- compact: exportMode
4308
+ sx: CARD_SX
4288
4309
  }), /*#__PURE__*/jsxRuntime.jsx(MetricDonutCard, {
4289
4310
  title: "Downsell",
4290
4311
  subtitle: "Acceptance & raised",
@@ -4293,8 +4314,7 @@ var ReportDetailsSection = function ReportDetailsSection(_ref) {
4293
4314
  acceptanceTrend: "".concat(formatNumber((downsellData === null || downsellData === void 0 ? void 0 : downsellData.acceptanceGrowth) || 0), "%"),
4294
4315
  raisedVal: "$".concat(formatNumber((downsellData === null || downsellData === void 0 ? void 0 : downsellData.raised) || 0)),
4295
4316
  raisedTrend: "".concat(formatNumber((downsellData === null || downsellData === void 0 ? void 0 : downsellData.raisedGrowth) || 0), "%"),
4296
- sx: cardSx,
4297
- compact: exportMode
4317
+ sx: CARD_SX
4298
4318
  }), /*#__PURE__*/jsxRuntime.jsx(MetricSparklineCard, {
4299
4319
  title: "Referrals",
4300
4320
  subtitle: "Revenue trend \xB7 last 30 days",
@@ -4316,254 +4336,66 @@ var ReportDetailsSection = function ReportDetailsSection(_ref) {
4316
4336
  label: "Conv. rate",
4317
4337
  value: "".concat(formatNumber((referralData === null || referralData === void 0 ? void 0 : referralData.conversionRate) || 0), "%")
4318
4338
  }],
4319
- sx: cardSx,
4320
- bottomSection: true,
4321
- compact: exportMode
4339
+ sx: CARD_SX,
4340
+ bottomSection: true
4322
4341
  })]
4323
4342
  });
4324
- if (section === "top") {
4325
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4326
- children: [campaignsRow, middleCards]
4327
- });
4328
- }
4329
- if (section === "bottom") {
4330
- return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4331
- children: bottomCards
4332
- });
4333
- }
4334
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4335
- sx: {
4336
- mt: exportMode ? 0 : 2
4337
- },
4338
- children: [campaignsRow, middleCards, /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4339
- sx: {
4340
- mt: exportMode ? 0.75 : 2
4341
- },
4342
- children: bottomCards
4343
- })]
4344
- });
4345
- };
4346
-
4347
- var COLORS$1 = ["#6363E6", "#10B981", "#06B6D4"];
4348
- var formatYLabel = function formatYLabel(v) {
4349
- if (v >= 10000) return "$".concat((v / 1000).toFixed(0), "K");
4350
- if (v >= 1000) return "$".concat((v / 1000).toFixed(1), "K");
4351
- return "$".concat(v.toFixed(0));
4352
- };
4353
- var ReportLineChart = function ReportLineChart(_ref) {
4354
- var _ref$series = _ref.series,
4355
- series = _ref$series === void 0 ? [] : _ref$series,
4356
- _ref$categories = _ref.categories,
4357
- categories = _ref$categories === void 0 ? [] : _ref$categories,
4358
- _ref$width = _ref.width,
4359
- width = _ref$width === void 0 ? 730 : _ref$width,
4360
- _ref$height = _ref.height,
4361
- height = _ref$height === void 0 ? 200 : _ref$height;
4362
- var allVals = series.flatMap(function (s) {
4363
- return s.data || [];
4343
+ if (section === "campaigns") return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4344
+ children: campaignsRow
4364
4345
  });
4365
- if (!allVals.length) {
4366
- return /*#__PURE__*/jsxRuntime.jsx("div", {
4367
- style: {
4368
- height: height,
4369
- background: "#F8FAFF",
4370
- borderRadius: 8
4371
- }
4372
- });
4373
- }
4374
- var PL = 44;
4375
- var PR = 12;
4376
- var PT = 10;
4377
- var PB = 24;
4378
- var IW = width - PL - PR;
4379
- var IH = height - PT - PB;
4380
- var max = Math.max.apply(Math, _toConsumableArray(allVals).concat([0]));
4381
- var range = max || 1;
4382
- var xp = function xp(i, n) {
4383
- return PL + i / Math.max(n - 1, 1) * IW;
4384
- };
4385
- var yp = function yp(v) {
4386
- return PT + IH - v / range * IH;
4387
- };
4388
- var yTicks = [0, 0.25, 0.5, 0.75, 1].map(function (t) {
4389
- return t * range;
4346
+ if (section === "middle") return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4347
+ sx: fourColGridSx(exportMode),
4348
+ children: middleCards
4390
4349
  });
4391
- var step = Math.max(1, Math.floor(categories.length / 6));
4392
- var shownCats = categories.filter(function (_, i) {
4393
- return i % step === 0 || i === categories.length - 1;
4350
+ if (section === "bottom") return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4351
+ sx: fourColGridSx(exportMode),
4352
+ children: bottomCards
4394
4353
  });
4395
- return /*#__PURE__*/jsxRuntime.jsxs("svg", {
4396
- width: width,
4397
- height: height,
4398
- style: {
4399
- display: "block"
4400
- },
4401
- children: [yTicks.map(function (v, i) {
4402
- var y = yp(v);
4403
- return /*#__PURE__*/jsxRuntime.jsxs("g", {
4404
- children: [/*#__PURE__*/jsxRuntime.jsx("line", {
4405
- x1: PL,
4406
- y1: y,
4407
- x2: width - PR,
4408
- y2: y,
4409
- stroke: "#E5E7EB",
4410
- strokeWidth: 1
4411
- }), /*#__PURE__*/jsxRuntime.jsx("text", {
4412
- x: PL - 6,
4413
- y: y + 4,
4414
- textAnchor: "end",
4415
- fontSize: 10,
4416
- fill: "#9CA3AF",
4417
- children: formatYLabel(v)
4418
- })]
4419
- }, i);
4420
- }), series.map(function (s, si) {
4421
- var data = s.data || [];
4422
- if (!data.length) return null;
4423
- var pathD = data.map(function (v, i) {
4424
- return "".concat(i === 0 ? "M" : "L").concat(xp(i, data.length).toFixed(1), ",").concat(yp(v).toFixed(1));
4425
- }).join(" ");
4426
- return /*#__PURE__*/jsxRuntime.jsx("path", {
4427
- d: pathD,
4428
- fill: "none",
4429
- stroke: COLORS$1[si % COLORS$1.length],
4430
- strokeWidth: 2.5,
4431
- strokeLinecap: "round",
4432
- strokeLinejoin: "round"
4433
- }, s.name || si);
4434
- }), shownCats.map(function (label, i) {
4435
- var origIdx = categories.indexOf(label);
4436
- var x = xp(origIdx < 0 ? i * step : origIdx, categories.length);
4437
- return /*#__PURE__*/jsxRuntime.jsx("text", {
4438
- x: x,
4439
- y: height - 6,
4440
- textAnchor: "middle",
4441
- fontSize: 10,
4442
- fill: "#9CA3AF",
4443
- children: label
4444
- }, i);
4354
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4355
+ children: [campaignsRow, /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4356
+ sx: fourColGridSx(exportMode),
4357
+ children: middleCards
4358
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4359
+ sx: fourColGridSx(exportMode),
4360
+ children: bottomCards
4445
4361
  })]
4446
4362
  });
4447
4363
  };
4448
4364
 
4449
- var LEGEND = [{
4450
- label: "Paid Ads",
4451
- color: "#6363E6"
4452
- }, {
4453
- label: "Organic",
4454
- color: "#10B981"
4455
- }, {
4456
- label: "Email",
4457
- color: "#06B6D4"
4458
- }];
4459
- var ReportExportChartCard = function ReportExportChartCard(_ref) {
4460
- var item = _ref.item,
4461
- _ref$chartWidth = _ref.chartWidth,
4462
- chartWidth = _ref$chartWidth === void 0 ? 730 : _ref$chartWidth;
4463
- return /*#__PURE__*/jsxRuntime.jsx(material.Card, {
4464
- sx: {
4465
- width: "100%",
4466
- boxShadow: "0 2px 12px rgba(0,0,0,0.05)",
4467
- borderRadius: 3,
4468
- border: "1px solid #f0f0f0"
4469
- },
4470
- children: /*#__PURE__*/jsxRuntime.jsxs(material.CardContent, {
4471
- sx: {
4472
- p: 2,
4473
- "&:last-child": {
4474
- pb: 2
4475
- }
4476
- },
4477
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4478
- sx: {
4479
- display: "flex",
4480
- justifyContent: "space-between",
4481
- alignItems: "flex-start",
4482
- mb: 1
4483
- },
4484
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4485
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4486
- sx: {
4487
- fontWeight: 700,
4488
- fontSize: 15,
4489
- color: "#000",
4490
- mb: 0.25
4491
- },
4492
- children: item.label
4493
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4494
- sx: {
4495
- fontSize: 11,
4496
- color: "rgba(0,0,0,0.4)",
4497
- mb: 1
4498
- },
4499
- children: item.subtitle || "Last 30 days · daily aggregation"
4500
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4501
- sx: {
4502
- display: "flex",
4503
- alignItems: "center",
4504
- gap: 1
4505
- },
4506
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4507
- sx: {
4508
- fontWeight: 700,
4509
- fontSize: 22,
4510
- color: "#000"
4511
- },
4512
- children: item.value
4513
- }), item.trend && /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4514
- sx: {
4515
- bgcolor: "#D1FAE5",
4516
- color: "#047857",
4517
- px: 1,
4518
- py: 0.25,
4519
- borderRadius: "100px",
4520
- fontSize: 11,
4521
- fontWeight: 600
4522
- },
4523
- children: ["\u25B2 ", item.trend]
4524
- })]
4525
- })]
4526
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4527
- sx: {
4528
- display: "flex",
4529
- gap: 1.5,
4530
- flexShrink: 0
4531
- },
4532
- children: LEGEND.map(function (leg) {
4533
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4534
- sx: {
4535
- display: "flex",
4536
- alignItems: "center",
4537
- gap: 0.5
4538
- },
4539
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
4540
- sx: {
4541
- width: 8,
4542
- height: 8,
4543
- borderRadius: "50%",
4544
- bgcolor: leg.color
4545
- }
4546
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
4547
- sx: {
4548
- fontSize: 10,
4549
- color: "rgba(0,0,0,0.55)"
4550
- },
4551
- children: leg.label
4552
- })]
4553
- }, leg.label);
4554
- })
4555
- })]
4556
- }), /*#__PURE__*/jsxRuntime.jsx(ReportLineChart, {
4557
- series: item.series || [],
4558
- categories: item.categories || [],
4559
- width: chartWidth,
4560
- height: 185
4561
- })]
4562
- })
4365
+ var ReportDetailsSection = function ReportDetailsSection(_ref) {
4366
+ var reportData = _ref.reportData,
4367
+ dateName = _ref.dateName,
4368
+ _ref$exportMode = _ref.exportMode,
4369
+ exportMode = _ref$exportMode === void 0 ? false : _ref$exportMode,
4370
+ _ref$section = _ref.section,
4371
+ section = _ref$section === void 0 ? "all" : _ref$section;
4372
+ var activeCampaigns = reportData.activeCampaigns,
4373
+ donorMix = reportData.donorMix,
4374
+ donationTypeData = reportData.donationTypeData,
4375
+ donorGeographyData = reportData.donorGeographyData,
4376
+ trafficSourceData = reportData.trafficSourceData,
4377
+ orderBumpData = reportData.orderBumpData,
4378
+ upsellData = reportData.upsellData,
4379
+ downsellData = reportData.downsellData,
4380
+ referralData = reportData.referralData,
4381
+ refundsChargebacksData = reportData.refundsChargebacksData;
4382
+ return /*#__PURE__*/jsxRuntime.jsx(OverallDetailsGrid, {
4383
+ exportMode: exportMode,
4384
+ section: section,
4385
+ activeCampaignsRows: activeCampaigns,
4386
+ donorMix: donorMix,
4387
+ donationTypeData: donationTypeData,
4388
+ donorGeographyData: donorGeographyData,
4389
+ trafficSourceData: trafficSourceData,
4390
+ orderBumpData: orderBumpData,
4391
+ upsellData: upsellData,
4392
+ downsellData: downsellData,
4393
+ referralData: referralData,
4394
+ refundsChargebacksData: refundsChargebacksData,
4395
+ dateName: dateName
4563
4396
  });
4564
4397
  };
4565
4398
 
4566
- var EXPORT_CHART_W = 730;
4567
4399
  var ReportBody = function ReportBody(_ref) {
4568
4400
  var _ref$apiData = _ref.apiData,
4569
4401
  apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
@@ -4579,31 +4411,29 @@ var ReportBody = function ReportBody(_ref) {
4579
4411
  var activeFilterChips = React.useMemo(function () {
4580
4412
  return getActiveFilterChips(apiData);
4581
4413
  }, [apiData]);
4582
- var chartBlock = exportMode ? /*#__PURE__*/jsxRuntime.jsx(ReportExportChartCard, {
4583
- item: reportData.mainChart,
4584
- chartWidth: EXPORT_CHART_W
4585
- }) : /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
4414
+ var chartBlock = /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
4586
4415
  container: true,
4587
- spacing: 2,
4416
+ spacing: exportMode ? "6px" : 2,
4588
4417
  sx: {
4589
- mb: 0
4418
+ mb: 0,
4419
+ mt: exportMode ? "6px" : 0
4590
4420
  },
4591
4421
  children: /*#__PURE__*/jsxRuntime.jsx(RenderChartCard, {
4592
4422
  item: _objectSpread2(_objectSpread2({}, reportData.mainChart), {}, {
4593
- height: 320
4423
+ height: exportMode ? 250 : 320,
4424
+ exportMode: exportMode
4594
4425
  }),
4595
4426
  index: 0,
4596
4427
  md: 12,
4597
4428
  isPremium: true,
4598
4429
  isPrimary: true,
4599
- metric: "Revenue",
4600
- type: "line"
4430
+ metric: "Revenue"
4601
4431
  })
4602
4432
  });
4603
4433
  if (variant === "page1") {
4604
4434
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
4605
4435
  sx: {
4606
- px: exportMode ? 2 : 0,
4436
+ px: exportMode ? 2.5 : 0,
4607
4437
  py: exportMode ? 1.5 : 0
4608
4438
  },
4609
4439
  children: [/*#__PURE__*/jsxRuntime.jsx(ReportHeader, {
@@ -4620,21 +4450,35 @@ var ReportBody = function ReportBody(_ref) {
4620
4450
  if (variant === "page2") {
4621
4451
  return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4622
4452
  sx: {
4623
- px: exportMode ? 2 : 0,
4453
+ px: exportMode ? 2.5 : 0,
4624
4454
  py: exportMode ? 1.5 : 0
4625
4455
  },
4626
4456
  children: /*#__PURE__*/jsxRuntime.jsx(ReportDetailsSection, {
4627
4457
  reportData: reportData,
4628
4458
  dateName: dateName,
4629
4459
  exportMode: exportMode,
4630
- section: "top"
4460
+ section: "campaigns"
4631
4461
  })
4632
4462
  });
4633
4463
  }
4634
4464
  if (variant === "page3") {
4635
4465
  return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4636
4466
  sx: {
4637
- px: exportMode ? 2 : 0,
4467
+ px: exportMode ? 2.5 : 0,
4468
+ py: exportMode ? 1.5 : 0
4469
+ },
4470
+ children: /*#__PURE__*/jsxRuntime.jsx(ReportDetailsSection, {
4471
+ reportData: reportData,
4472
+ dateName: dateName,
4473
+ exportMode: exportMode,
4474
+ section: "middle"
4475
+ })
4476
+ });
4477
+ }
4478
+ if (variant === "page4") {
4479
+ return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4480
+ sx: {
4481
+ px: exportMode ? 2.5 : 0,
4638
4482
  py: exportMode ? 1.5 : 0
4639
4483
  },
4640
4484
  children: /*#__PURE__*/jsxRuntime.jsx(ReportDetailsSection, {
@@ -4661,12 +4505,9 @@ var ReportBody = function ReportBody(_ref) {
4661
4505
  };
4662
4506
 
4663
4507
  var PAGE_W = 794;
4664
- var PAGE_H = 1123;
4665
4508
  var pageStyle = {
4666
4509
  width: PAGE_W,
4667
- height: PAGE_H,
4668
4510
  background: "#F3F4F6",
4669
- overflow: "hidden",
4670
4511
  boxSizing: "border-box",
4671
4512
  fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif"
4672
4513
  };
@@ -4689,7 +4530,8 @@ var ReportExportLayout = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
4689
4530
  ref: ref,
4690
4531
  style: {
4691
4532
  display: "inline-flex",
4692
- flexDirection: "column"
4533
+ flexDirection: "column",
4534
+ width: PAGE_W
4693
4535
  },
4694
4536
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
4695
4537
  "data-export-page": "1",
@@ -4709,6 +4551,12 @@ var ReportExportLayout = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
4709
4551
  children: /*#__PURE__*/jsxRuntime.jsx(ReportBody, _objectSpread2(_objectSpread2({}, bodyProps), {}, {
4710
4552
  variant: "page3"
4711
4553
  }))
4554
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
4555
+ "data-export-page": "4",
4556
+ style: pageStyle,
4557
+ children: /*#__PURE__*/jsxRuntime.jsx(ReportBody, _objectSpread2(_objectSpread2({}, bodyProps), {}, {
4558
+ variant: "page4"
4559
+ }))
4712
4560
  })]
4713
4561
  })
4714
4562
  });
@@ -4717,13 +4565,14 @@ ReportExportLayout.displayName = "ReportExportLayout";
4717
4565
 
4718
4566
  /**
4719
4567
  * Captures [data-export-page] elements and saves a multi-page A4 PDF.
4568
+ * Each page is scaled to fit without cropping.
4720
4569
  */
4721
4570
  function exportReportPdf(_x, _x2) {
4722
4571
  return _exportReportPdf.apply(this, arguments);
4723
4572
  }
4724
4573
  function _exportReportPdf() {
4725
4574
  _exportReportPdf = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(container, filename) {
4726
- var pageEls, _yield$Promise$all, _yield$Promise$all2, jsPDF, html2canvasModule, html2canvas, doc, pdfW, pdfH, i, el, canvas, safeDate;
4575
+ var pageEls, _yield$Promise$all, _yield$Promise$all2, jsPDF, html2canvasModule, html2canvas, doc, pdfW, pdfH, i, el, captureHeight, canvas, imgData, imgW, imgH, scale, drawW, drawH, offsetX, offsetY, safeDate;
4727
4576
  return _regenerator().w(function (_context) {
4728
4577
  while (1) switch (_context.n) {
4729
4578
  case 0:
@@ -4761,22 +4610,31 @@ function _exportReportPdf() {
4761
4610
  break;
4762
4611
  }
4763
4612
  el = pageEls[i];
4613
+ captureHeight = el.scrollHeight || el.offsetHeight;
4764
4614
  _context.n = 5;
4765
4615
  return html2canvas(el, {
4766
4616
  scale: 2,
4767
4617
  useCORS: true,
4768
4618
  backgroundColor: "#F3F4F6",
4769
4619
  width: el.offsetWidth,
4770
- height: el.offsetHeight,
4620
+ height: captureHeight,
4771
4621
  windowWidth: el.offsetWidth,
4772
- windowHeight: el.offsetHeight,
4622
+ windowHeight: captureHeight,
4773
4623
  logging: false,
4774
4624
  foreignObjectRendering: false
4775
4625
  });
4776
4626
  case 5:
4777
4627
  canvas = _context.v;
4628
+ imgData = canvas.toDataURL("image/png");
4629
+ imgW = canvas.width;
4630
+ imgH = canvas.height;
4631
+ scale = Math.min(pdfW / imgW, pdfH / imgH);
4632
+ drawW = imgW * scale;
4633
+ drawH = imgH * scale;
4634
+ offsetX = (pdfW - drawW) / 2;
4635
+ offsetY = 0;
4778
4636
  if (i > 0) doc.addPage();
4779
- doc.addImage(canvas.toDataURL("image/png"), "PNG", 0, 0, pdfW, pdfH, undefined, "FAST");
4637
+ doc.addImage(imgData, "PNG", offsetX, offsetY, drawW, drawH, undefined, "FAST");
4780
4638
  case 6:
4781
4639
  i++;
4782
4640
  _context.n = 4;
@@ -4860,7 +4718,7 @@ var NewOverview = function NewOverview(_ref) {
4860
4718
  case 1:
4861
4719
  _context.n = 2;
4862
4720
  return new Promise(function (r) {
4863
- return setTimeout(r, 600);
4721
+ return setTimeout(r, 1500);
4864
4722
  });
4865
4723
  case 2:
4866
4724
  container = exportLayoutRef.current;
@@ -14610,7 +14468,7 @@ var MetricCard = function MetricCard(_ref) {
14610
14468
  };
14611
14469
 
14612
14470
  var OverallSection = function OverallSection(_ref) {
14613
- var _apiData$overviewStat, _apiData$overviewStat2, _apiData$overviewStat3, _apiData$overviewStat4, _apiData$overviewStat5, _apiData$overviewStat6, _apiData$overviewStat7, _apiData$overviewStat8, _apiData$overviewStat9, _apiData$overviewStat0, _apiData$overviewStat1, _apiData$overviewStat10, _apiData$roasCard, _apiData$roasCardPrev, _apiData$overviewStat11, _apiData$overviewStat12, _apiData$overviewStat13, _orderBumpData$chart, _orderBumpData$peakDa, _orderBumpData$peakDa2, _referralData$chartDa;
14471
+ var _apiData$overviewStat, _apiData$overviewStat2, _apiData$overviewStat3, _apiData$overviewStat4, _apiData$overviewStat5, _apiData$overviewStat6, _apiData$overviewStat7, _apiData$overviewStat8, _apiData$overviewStat9, _apiData$overviewStat0, _apiData$overviewStat1, _apiData$overviewStat10, _apiData$roasCard, _apiData$roasCardPrev, _apiData$overviewStat11, _apiData$overviewStat12, _apiData$overviewStat13;
14614
14472
  var _ref$apiData = _ref.apiData,
14615
14473
  apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
14616
14474
  primaryCharts = _ref.primaryCharts,
@@ -15111,188 +14969,38 @@ var OverallSection = function OverallSection(_ref) {
15111
14969
  isPrimary: true,
15112
14970
  metric: activeMetric.includes("Raised") || activeMetric.includes("donation") ? "Revenue" : "Donors"
15113
14971
  })
15114
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Grid, {
15115
- container: true,
15116
- spacing: "6px",
15117
- sx: {
15118
- mt: "6px"
15119
- },
15120
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Grid, {
15121
- item: true,
15122
- xs: 12,
15123
- md: 9,
15124
- sx: {
15125
- paddingTop: "0px !important"
15126
- },
15127
- children: /*#__PURE__*/jsxRuntime.jsx(ActiveCampaignsCard, {
15128
- title: "Active campaigns",
15129
- subtitle: "Live fundraisers ranked by velocity",
15130
- columns: ["Campaign", "Raised", "Progress", "Donors", "Avg gift"
15131
- // "Status",
15132
- ],
15133
- rows: activeCampaignsData.map(function (campaign) {
15134
- return {
15135
- id: campaign.campaignName ? campaign.campaignName.split(" ").filter(Boolean).map(function (word) {
15136
- return word[0];
15137
- }).join("").toUpperCase().slice(0, 2) : "??",
15138
- name: campaign.title || "Untitled Campaign",
15139
- val1: "$".concat(formatNumber(campaign.collectedAmount || 0)),
15140
- type: "progress",
15141
- progress: Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100),
15142
- val3: formatNumber(campaign.uniqueDonationsCount || 0),
15143
- val4: "$".concat(formatNumber(campaign.avgGift || 0))
15144
- };
15145
- })
15146
- })
15147
- }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
15148
- item: true,
15149
- xs: 12,
15150
- md: 3,
15151
- sx: {
15152
- display: "flex",
15153
- paddingTop: "0px !important",
15154
- marginTop: {
15155
- xs: "6px",
15156
- md: "0px"
15157
- }
15158
- },
15159
- children: /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
15160
- title: "Donor mix",
15161
- subtitle: "Acquisition vs retention",
15162
- series: [newDonorsCount, returningDonorsCount],
15163
- labels: ["New donors", "Returning"],
15164
- colors: ["rgb(99, 99, 230)", "#10B981"],
15165
- centerLabel: "donors",
15166
- centerValue: totalDonorsMix.toString(),
15167
- items: [{
15168
- label: "New donors",
15169
- val: "".concat(newDonorsCount, " \xB7 ").concat(newDonorsPerc, "%"),
15170
- color: "rgb(99, 99, 230)"
15171
- }, {
15172
- label: "Returning",
15173
- val: "".concat(returningDonorsCount, " \xB7 ").concat(returningDonorsPerc, "%"),
15174
- color: "#10B981"
15175
- }],
15176
- bottomSummaryValue: "$".concat(avgGift),
15177
- bottomSummaryTrend: "".concat(donorMixPrev, "% vs ").concat(dateName || "last month"),
15178
- sx: {
15179
- width: "100%"
15180
- }
15181
- })
15182
- })]
15183
- }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
15184
- sx: {
15185
- display: "grid",
15186
- gridTemplateColumns: {
15187
- xs: "1fr",
15188
- // 1 card
15189
- sm: "repeat(2, 1fr)",
15190
- // 2 cards
15191
- md: "repeat(4, 1fr)" // 4 cards
15192
- },
15193
- gap: "6px",
15194
- mt: "6px",
15195
- alignItems: "stretch"
14972
+ }), /*#__PURE__*/jsxRuntime.jsx(OverallDetailsGrid, {
14973
+ activeCampaignsRows: activeCampaignsData.map(function (campaign) {
14974
+ return {
14975
+ id: campaign.campaignName ? campaign.campaignName.split(" ").filter(Boolean).map(function (word) {
14976
+ return word[0];
14977
+ }).join("").toUpperCase().slice(0, 2) : "??",
14978
+ name: campaign.title || "Untitled Campaign",
14979
+ val1: "$".concat(formatNumber(campaign.collectedAmount || 0)),
14980
+ type: "progress",
14981
+ progress: Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100),
14982
+ val3: formatNumber(campaign.uniqueDonationsCount || 0),
14983
+ val4: "$".concat(formatNumber(campaign.avgGift || 0))
14984
+ };
14985
+ }),
14986
+ donorMix: {
14987
+ newDonors: newDonorsCount,
14988
+ returningDonors: returningDonorsCount,
14989
+ totalMix: totalDonorsMix,
14990
+ newPct: newDonorsPerc,
14991
+ retPct: returningDonorsPerc,
14992
+ avgGift: avgGift,
14993
+ donorMixPrev: donorMixPrev
15196
14994
  },
15197
- children: [/*#__PURE__*/jsxRuntime.jsx(DonationTypeBarChart, {
15198
- sx: {
15199
- maxHeight: 280
15200
- },
15201
- donationTypeData: donationTypeData
15202
- }), /*#__PURE__*/jsxRuntime.jsx(PaidDonorGeographyCard, {
15203
- sx: {
15204
- maxHeight: 280
15205
- },
15206
- donorGeographyData: donorGeographyData
15207
- }), /*#__PURE__*/jsxRuntime.jsx(RefundsChargebacksCard, {
15208
- sx: {
15209
- maxHeight: 280
15210
- },
15211
- refundsChargebacksData: refundsChargebacksData
15212
- }), /*#__PURE__*/jsxRuntime.jsx(TrafficSourceCard, {
15213
- sx: {
15214
- maxHeight: 280
15215
- },
15216
- trafficSourceData: (trafficSourceData === null || trafficSourceData === void 0 ? void 0 : trafficSourceData.data) || [],
15217
- total: "$".concat(formatNumber((trafficSourceData === null || trafficSourceData === void 0 ? void 0 : trafficSourceData.totalRevenue) || 0))
15218
- }), /*#__PURE__*/jsxRuntime.jsx(MetricSparklineCard, {
15219
- title: "Order Bump",
15220
- subtitle: "Revenue trend \xB7 last 30 days",
15221
- value: "$".concat(formatNumber((orderBumpData === null || orderBumpData === void 0 ? void 0 : orderBumpData.totalRevenue) || 0)),
15222
- trend: "".concat((orderBumpData === null || orderBumpData === void 0 ? void 0 : orderBumpData.growthPercentage) >= 0 ? "▲" : "▼", " ").concat(Math.abs((orderBumpData === null || orderBumpData === void 0 ? void 0 : orderBumpData.growthPercentage) || 0).toFixed(1), "% vs last month"),
15223
- chartData: (orderBumpData === null || orderBumpData === void 0 || (_orderBumpData$chart = orderBumpData.chart) === null || _orderBumpData$chart === void 0 ? void 0 : _orderBumpData$chart.map(function (item) {
15224
- return {
15225
- label: item.label,
15226
- value: item.revenue
15227
- };
15228
- })) || [],
15229
- footerMetrics: [{
15230
- label: "Avg / Day",
15231
- value: "$".concat(formatNumber((orderBumpData === null || orderBumpData === void 0 ? void 0 : orderBumpData.averagePerDay) || 0))
15232
- }, {
15233
- label: "Orders",
15234
- value: formatNumber((orderBumpData === null || orderBumpData === void 0 ? void 0 : orderBumpData.totalOrders) || 0)
15235
- }, {
15236
- label: "Peak Day",
15237
- value: "$".concat(formatNumber((orderBumpData === null || orderBumpData === void 0 || (_orderBumpData$peakDa = orderBumpData.peakDay) === null || _orderBumpData$peakDa === void 0 ? void 0 : _orderBumpData$peakDa.amount) || 0)),
15238
- subValue: orderBumpData === null || orderBumpData === void 0 || (_orderBumpData$peakDa2 = orderBumpData.peakDay) === null || _orderBumpData$peakDa2 === void 0 ? void 0 : _orderBumpData$peakDa2.date
15239
- }],
15240
- sx: {
15241
- maxHeight: 280
15242
- },
15243
- bottomSection: true
15244
- }), /*#__PURE__*/jsxRuntime.jsx(MetricDonutCard, {
15245
- title: "Upsell",
15246
- subtitle: "Acceptance & raised",
15247
- acceptanceRate: (upsellData === null || upsellData === void 0 ? void 0 : upsellData.acceptanceRate) || 0,
15248
- acceptanceVal: "".concat(formatNumber((upsellData === null || upsellData === void 0 ? void 0 : upsellData.totalUpsellsAttached) || 0)),
15249
- acceptanceTrend: "".concat((upsellData === null || upsellData === void 0 ? void 0 : upsellData.acceptanceGrowth) >= 0 ? "▲" : "▼", " ").concat(Math.abs((upsellData === null || upsellData === void 0 ? void 0 : upsellData.acceptanceGrowth) || 0).toFixed(1), "%"),
15250
- raisedVal: "$".concat(formatNumber((upsellData === null || upsellData === void 0 ? void 0 : upsellData.raised) || 0)),
15251
- raisedTrend: "".concat((upsellData === null || upsellData === void 0 ? void 0 : upsellData.raisedGrowth) >= 0 ? "▲" : "▼", " ").concat(Math.abs((upsellData === null || upsellData === void 0 ? void 0 : upsellData.raisedGrowth) || 0).toFixed(1), "%"),
15252
- sx: {
15253
- maxHeight: 280
15254
- }
15255
- }), /*#__PURE__*/jsxRuntime.jsx(MetricDonutCard, {
15256
- title: "Downsell",
15257
- subtitle: "Acceptance & raised",
15258
- acceptanceRate: (downsellData === null || downsellData === void 0 ? void 0 : downsellData.acceptanceRate) || 0,
15259
- acceptanceVal: "".concat(formatNumber((downsellData === null || downsellData === void 0 ? void 0 : downsellData.acceptanceRate) || 0), "%"),
15260
- acceptanceTrend: "".concat(formatNumber((downsellData === null || downsellData === void 0 ? void 0 : downsellData.acceptanceGrowth) || 0), "%"),
15261
- raisedVal: "$".concat(formatNumber((downsellData === null || downsellData === void 0 ? void 0 : downsellData.raised) || 0)),
15262
- raisedTrend: "".concat(formatNumber((downsellData === null || downsellData === void 0 ? void 0 : downsellData.raisedGrowth) || 0), "%"),
15263
- sx: {
15264
- maxHeight: 280
15265
- }
15266
- }), /*#__PURE__*/jsxRuntime.jsx(MetricSparklineCard, {
15267
- title: "Referrals",
15268
- subtitle: "Revenue trend \xB7 last 30 days",
15269
- value: "$".concat(formatNumber((referralData === null || referralData === void 0 ? void 0 : referralData.totalRevenue) || 0)),
15270
- trend: "\u25B2 ".concat((referralData === null || referralData === void 0 ? void 0 : referralData.growthPercentage) || 0, "% vs last month"),
15271
- chartData: (referralData === null || referralData === void 0 || (_referralData$chartDa = referralData.chartData) === null || _referralData$chartDa === void 0 ? void 0 : _referralData$chartDa.map(function (item) {
15272
- return {
15273
- label: item.date,
15274
- value: item.revenue
15275
- };
15276
- })) || []
15277
- // chartData={
15278
- // referralData?.chartData?.map(item => item.revenue) || []
15279
- // }
15280
- ,
15281
- footerMetrics: [{
15282
- label: "Referrers",
15283
- value: formatNumber((referralData === null || referralData === void 0 ? void 0 : referralData.totalReferrers) || 0)
15284
- }, {
15285
- label: "Avg gift",
15286
- value: "$".concat(formatNumber((referralData === null || referralData === void 0 ? void 0 : referralData.averageGift) || 0))
15287
- }, {
15288
- label: "Conv. rate",
15289
- value: "".concat(formatNumber((referralData === null || referralData === void 0 ? void 0 : referralData.conversionRate) || 0), "%")
15290
- }],
15291
- sx: {
15292
- maxHeight: 280
15293
- },
15294
- bottomSection: true
15295
- })]
14995
+ donationTypeData: donationTypeData,
14996
+ donorGeographyData: donorGeographyData,
14997
+ trafficSourceData: trafficSourceData,
14998
+ orderBumpData: orderBumpData,
14999
+ upsellData: upsellData,
15000
+ downsellData: downsellData,
15001
+ referralData: referralData,
15002
+ refundsChargebacksData: refundsChargebacksData,
15003
+ dateName: dateName
15296
15004
  })]
15297
15005
  });
15298
15006
  };