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