@ammarkhalidfarooq/dashboard-package 0.5.13 → 0.5.14

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
@@ -940,7 +940,7 @@ var NewOverview = function NewOverview(_ref) {
940
940
  if (exportTrigger <= 0) return;
941
941
  var buildAndDownloadPdf = /*#__PURE__*/function () {
942
942
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
943
- var _apiData$overviewStat, _apiData$overviewStat2, _apiData$trafficSourc, _apiData$roasCard, _apiData$overviewStat3, _apiData$overviewStat4, _apiData$overviewStat5, _apiData$overviewStat6, _apiData$overviewStat7, _apiData$overviewStat8, _doc$lastAutoTable, _apiData$orderBumpDet, _apiData$upSellDetail, _apiData$downSellDeta, _apiData$referralDeta, _doc$lastAutoTable2, _yield$Promise$all, _yield$Promise$all2, jsPDF, autoTableModule, autoTable, growth, overview, dateLabel, generatedAt, generatedLabel, fmtPct, fmtSigned, doc, pageWidth, marginX, contentWidth, cardGap, cardWidth, addHeader, addFooter, metricCard, donorMixRaw, newDonorsCount, returningDonorsCount, avgGift, newDonorsObj, returningDonorsObj, totalAmount, totalCount, activeCampaignRows, trafficRows, donorMixRows, refundsData, totalRaised, netRaised, totalDonors, convRate, avgDonation, totalVisits, passThrough, refundRate, chargebackRate, page1Cards, y, trendY, donorCardTop, miscRows, safeDate, _t;
943
+ var _apiData$overviewStat, _apiData$overviewStat2, _apiData$trafficSourc, _apiData$recurringBar, _apiData$recurringBar2, _apiData$roasCard, _apiData$overviewStat3, _apiData$overviewStat4, _apiData$overviewStat5, _apiData$overviewStat6, _apiData$overviewStat7, _apiData$overviewStat8, _doc$lastAutoTable, _doc$lastAutoTable2, _apiData$orderBumpDet, _apiData$orderBumpDet2, _apiData$orderBumpDet3, _apiData$orderBumpDet4, _apiData$upSellDetail, _apiData$upSellDetail2, _apiData$downSellDeta, _apiData$downSellDeta2, _apiData$referralDeta, _apiData$referralDeta2, _yield$Promise$all, _yield$Promise$all2, jsPDF, autoTableModule, autoTable, growth, overview, dateLabel, generatedAt, generatedLabel, fmtPct, fmtSigned, doc, pageWidth, marginX, contentWidth, cardGap, cardWidth, addHeader, addFooter, metricCard, donorMixRaw, newDonorsCount, returningDonorsCount, avgGift, newDonorsObj, returningDonorsObj, totalAmount, totalCount, activeCampaignRows, trafficRows, donorMixRows, recurringTotal, oneTimeTotalValue, donorGeoRows, refundsData, totalRaised, netRaised, totalDonors, convRate, avgDonation, totalVisits, passThrough, refundRate, chargebackRate, page1Cards, y, trendY, donorCardTop, cardsTop, halfGap, halfW, drawInfoCard, safeDate, _t;
944
944
  return _regenerator().w(function (_context) {
945
945
  while (1) switch (_context.p = _context.n) {
946
946
  case 0:
@@ -987,7 +987,7 @@ var NewOverview = function NewOverview(_ref) {
987
987
  doc.text("PERFORMANCE REPORT", marginX, 50);
988
988
  doc.setTextColor(17, 24, 39);
989
989
  doc.setFontSize(13);
990
- doc.text("Dashboard overview - Overall", marginX, 72);
990
+ doc.text("Dashboard overview Overall", marginX, 72);
991
991
  doc.setFont("helvetica", "normal");
992
992
  doc.setFontSize(10);
993
993
  doc.setTextColor(107, 114, 128);
@@ -1055,12 +1055,17 @@ var NewOverview = function NewOverview(_ref) {
1055
1055
  avgGift = donorMixRaw.avgGift || 0;
1056
1056
  }
1057
1057
  activeCampaignRows = ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).map(function (campaign) {
1058
- return [campaign.title || "Untitled Campaign", "$".concat(formatNumber(campaign.collectedAmount || 0)), "".concat(Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100), "%"), "".concat(formatNumber(campaign.uniqueDonationsCount || 0)), "$".concat(formatNumber(campaign.avgGift || 0))];
1058
+ return [campaign.title || "Untitled Campaign", "$".concat(formatNumber(campaign.collectedAmount || 0)), "".concat(Math.round((campaign.collectedAmount || 0) / (campaign.usdTargetAmount || 1) * 100), "%"), "".concat(formatNumber(campaign.uniqueDonationsCount || 0)), "$".concat(formatNumber(campaign.avgGift || 0)), campaign.status || "Active"];
1059
1059
  });
1060
1060
  trafficRows = ((apiData === null || apiData === void 0 || (_apiData$trafficSourc = apiData.trafficSourceData) === null || _apiData$trafficSourc === void 0 ? void 0 : _apiData$trafficSourc.data) || []).map(function (item) {
1061
1061
  return [(item === null || item === void 0 ? void 0 : item.source) || (item === null || item === void 0 ? void 0 : item.name) || "-", "".concat(formatNumber((item === null || item === void 0 ? void 0 : item.donors) || (item === null || item === void 0 ? void 0 : item.totalDonors) || 0)), "$".concat(formatNumber((item === null || item === void 0 ? void 0 : item.revenue) || (item === null || item === void 0 ? void 0 : item.raised) || 0))];
1062
1062
  });
1063
1063
  donorMixRows = [["New donors", "".concat(formatNumber(newDonorsCount))], ["Returning donors", "".concat(formatNumber(returningDonorsCount))], ["Avg gift", "$".concat(formatNumber(avgGift))]];
1064
+ recurringTotal = Number((apiData === null || apiData === void 0 || (_apiData$recurringBar = apiData.recurringBarChartData) === null || _apiData$recurringBar === void 0 ? void 0 : _apiData$recurringBar.recurringTotal) || 0);
1065
+ oneTimeTotalValue = Number((apiData === null || apiData === void 0 || (_apiData$recurringBar2 = apiData.recurringBarChartData) === null || _apiData$recurringBar2 === void 0 ? void 0 : _apiData$recurringBar2.oneTimeTotal) || 0);
1066
+ donorGeoRows = ((apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography) || []).slice(0, 6).map(function (item) {
1067
+ return [item.country || item.name || "-", "".concat(formatNumber(item.totalDonors || item.donors || 0)), "".concat(formatNumber(item.percentage || 0), "%")];
1068
+ });
1064
1069
  refundsData = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
1065
1070
  totalRaised = Number((overview === null || overview === void 0 ? void 0 : overview.totalRevenue) || 0);
1066
1071
  netRaised = Number((overview === null || overview === void 0 ? void 0 : overview.netRevenue) || 0);
@@ -1173,10 +1178,14 @@ var NewOverview = function NewOverview(_ref) {
1173
1178
  doc.setFontSize(9.5);
1174
1179
  doc.setTextColor(107, 114, 128);
1175
1180
  doc.text("Live fundraisers ranked by velocity", marginX, 126);
1181
+ doc.setTextColor(99, 102, 241);
1182
+ doc.text("View all →", pageWidth - marginX, 126, {
1183
+ align: "right"
1184
+ });
1176
1185
  autoTable(doc, {
1177
1186
  startY: 136,
1178
- head: [["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT"]],
1179
- body: activeCampaignRows.length ? activeCampaignRows : [["-", "$0", "0%", "0", "$0"]],
1187
+ head: [["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT", "STATUS"]],
1188
+ body: activeCampaignRows.length ? activeCampaignRows : [["-", "$0", "0%", "0", "$0", "-"]],
1180
1189
  margin: {
1181
1190
  left: marginX,
1182
1191
  right: marginX
@@ -1241,27 +1250,93 @@ var NewOverview = function NewOverview(_ref) {
1241
1250
  fillColor: [248, 250, 252]
1242
1251
  }
1243
1252
  });
1244
- miscRows = [["Refunds", "".concat(formatNumber(refundRate), "%")], ["Chargebacks", "".concat(formatNumber(chargebackRate), "%")], ["Order Bump", "$".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$orderBumpDet = apiData.orderBumpDetails) === null || _apiData$orderBumpDet === void 0 ? void 0 : _apiData$orderBumpDet.totalRevenue) || 0))], ["Upsell Raised", "$".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$upSellDetail = apiData.upSellDetails) === null || _apiData$upSellDetail === void 0 ? void 0 : _apiData$upSellDetail.raised) || 0))], ["Downsell Raised", "$".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$downSellDeta = apiData.downSellDetails) === null || _apiData$downSellDeta === void 0 ? void 0 : _apiData$downSellDeta.raised) || 0))], ["Referrals", "$".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$referralDeta = apiData.referralDetails) === null || _apiData$referralDeta === void 0 ? void 0 : _apiData$referralDeta.totalRevenue) || 0))]];
1245
- autoTable(doc, {
1246
- startY: (((_doc$lastAutoTable2 = doc.lastAutoTable) === null || _doc$lastAutoTable2 === void 0 ? void 0 : _doc$lastAutoTable2.finalY) || donorCardTop + 120) + 12,
1247
- head: [["Additional Blocks", "Value"]],
1248
- body: miscRows,
1249
- margin: {
1250
- left: marginX,
1251
- right: marginX
1252
- },
1253
- styles: {
1254
- fontSize: 9,
1255
- cellPadding: 5
1256
- },
1257
- headStyles: {
1258
- fillColor: [241, 245, 249],
1259
- textColor: [51, 65, 85]
1260
- },
1261
- alternateRowStyles: {
1262
- fillColor: [248, 250, 252]
1263
- }
1253
+ cardsTop = (((_doc$lastAutoTable2 = doc.lastAutoTable) === null || _doc$lastAutoTable2 === void 0 ? void 0 : _doc$lastAutoTable2.finalY) || donorCardTop + 120) + 12;
1254
+ halfGap = 12;
1255
+ halfW = (contentWidth - halfGap) / 2;
1256
+ drawInfoCard = function drawInfoCard(_ref4) {
1257
+ var x = _ref4.x,
1258
+ y = _ref4.y,
1259
+ w = _ref4.w,
1260
+ h = _ref4.h,
1261
+ title = _ref4.title,
1262
+ subtitle = _ref4.subtitle,
1263
+ _ref4$lines = _ref4.lines,
1264
+ lines = _ref4$lines === void 0 ? [] : _ref4$lines;
1265
+ doc.setDrawColor(229, 231, 235);
1266
+ doc.roundedRect(x, y, w, h, 6, 6);
1267
+ doc.setFont("helvetica", "bold");
1268
+ doc.setTextColor(17, 24, 39);
1269
+ doc.setFontSize(10);
1270
+ doc.text(title, x + 10, y + 16);
1271
+ doc.setFont("helvetica", "normal");
1272
+ doc.setFontSize(8.5);
1273
+ doc.setTextColor(107, 114, 128);
1274
+ doc.text(subtitle, x + 10, y + 30);
1275
+ doc.setTextColor(55, 65, 81);
1276
+ lines.forEach(function (line, idx) {
1277
+ doc.text(line, x + 10, y + 46 + idx * 12, {
1278
+ maxWidth: w - 20
1279
+ });
1280
+ });
1281
+ };
1282
+ drawInfoCard({
1283
+ x: marginX,
1284
+ y: cardsTop,
1285
+ w: halfW,
1286
+ h: 86,
1287
+ title: "Recurring vs one-time",
1288
+ subtitle: "Donation type · weekly",
1289
+ lines: ["Recurring $".concat(formatNumber(recurringTotal)), "One-time $".concat(formatNumber(oneTimeTotalValue))]
1264
1290
  });
1291
+ drawInfoCard({
1292
+ x: marginX + halfW + halfGap,
1293
+ y: cardsTop,
1294
+ w: halfW,
1295
+ h: 86,
1296
+ title: "Refunds & chargebacks",
1297
+ subtitle: "Trust health · 30-day window",
1298
+ lines: ["Refunds ".concat(fmtPct(refundRate, 2), " (").concat(fmtSigned(refundsData === null || refundsData === void 0 ? void 0 : refundsData.refundRateChange, "pp"), ")"), "Chargebacks ".concat(fmtPct(chargebackRate, 2), " (").concat(fmtSigned(refundsData === null || refundsData === void 0 ? void 0 : refundsData.chargebackRateChange, "pp"), ")"), "$".concat(formatNumber((refundsData === null || refundsData === void 0 ? void 0 : refundsData.refundAmount) || 0), " refunded \xB7 $").concat(formatNumber((refundsData === null || refundsData === void 0 ? void 0 : refundsData.disputedAmount) || 0), " disputed")]
1299
+ });
1300
+ drawInfoCard({
1301
+ x: marginX,
1302
+ y: cardsTop + 96,
1303
+ w: halfW,
1304
+ h: 88,
1305
+ title: "Order Bump",
1306
+ subtitle: "Revenue trend · last 30 days",
1307
+ lines: ["$".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$orderBumpDet = apiData.orderBumpDetails) === null || _apiData$orderBumpDet === void 0 ? void 0 : _apiData$orderBumpDet.totalRevenue) || 0), " (").concat(fmtSigned(apiData === null || apiData === void 0 || (_apiData$orderBumpDet2 = apiData.orderBumpDetails) === null || _apiData$orderBumpDet2 === void 0 ? void 0 : _apiData$orderBumpDet2.growthPercentage, "%"), ")"), "Avg/day $".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$orderBumpDet3 = apiData.orderBumpDetails) === null || _apiData$orderBumpDet3 === void 0 ? void 0 : _apiData$orderBumpDet3.averagePerDay) || 0), " \xB7 Orders ").concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$orderBumpDet4 = apiData.orderBumpDetails) === null || _apiData$orderBumpDet4 === void 0 ? void 0 : _apiData$orderBumpDet4.totalOrders) || 0))]
1308
+ });
1309
+ drawInfoCard({
1310
+ x: marginX + halfW + halfGap,
1311
+ y: cardsTop + 96,
1312
+ w: halfW,
1313
+ h: 88,
1314
+ title: "Upsell / Downsell / Referrals",
1315
+ subtitle: "Acceptance & raised",
1316
+ lines: ["Upsell $".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$upSellDetail = apiData.upSellDetails) === null || _apiData$upSellDetail === void 0 ? void 0 : _apiData$upSellDetail.raised) || 0), " \xB7 ").concat(fmtPct((apiData === null || apiData === void 0 || (_apiData$upSellDetail2 = apiData.upSellDetails) === null || _apiData$upSellDetail2 === void 0 ? void 0 : _apiData$upSellDetail2.acceptanceRate) || 0, 1), " accepted"), "Downsell $".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$downSellDeta = apiData.downSellDetails) === null || _apiData$downSellDeta === void 0 ? void 0 : _apiData$downSellDeta.raised) || 0), " \xB7 ").concat(fmtPct((apiData === null || apiData === void 0 || (_apiData$downSellDeta2 = apiData.downSellDetails) === null || _apiData$downSellDeta2 === void 0 ? void 0 : _apiData$downSellDeta2.acceptanceRate) || 0, 1), " accepted"), "Referrals $".concat(formatNumber((apiData === null || apiData === void 0 || (_apiData$referralDeta = apiData.referralDetails) === null || _apiData$referralDeta === void 0 ? void 0 : _apiData$referralDeta.totalRevenue) || 0), " \xB7 ").concat(fmtPct((apiData === null || apiData === void 0 || (_apiData$referralDeta2 = apiData.referralDetails) === null || _apiData$referralDeta2 === void 0 ? void 0 : _apiData$referralDeta2.conversionRate) || 0, 1), " conv.")]
1317
+ });
1318
+ if (donorGeoRows.length > 0) {
1319
+ autoTable(doc, {
1320
+ startY: cardsTop + 192,
1321
+ head: [["COUNTRY", "DONORS", "SHARE"]],
1322
+ body: donorGeoRows,
1323
+ margin: {
1324
+ left: marginX,
1325
+ right: marginX
1326
+ },
1327
+ styles: {
1328
+ fontSize: 9,
1329
+ cellPadding: 4.5
1330
+ },
1331
+ headStyles: {
1332
+ fillColor: [241, 245, 249],
1333
+ textColor: [51, 65, 85]
1334
+ },
1335
+ alternateRowStyles: {
1336
+ fillColor: [248, 250, 252]
1337
+ }
1338
+ });
1339
+ }
1265
1340
  addFooter(2, 2);
1266
1341
  safeDate = new Date().toISOString().slice(0, 10);
1267
1342
  doc.save("DashboardOverview_report_".concat(safeDate, ".pdf"));