@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.cjs.js CHANGED
@@ -942,7 +942,7 @@ var NewOverview = function NewOverview(_ref) {
942
942
  if (exportTrigger <= 0) return;
943
943
  var buildAndDownloadPdf = /*#__PURE__*/function () {
944
944
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
945
- 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;
945
+ 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;
946
946
  return _regenerator().w(function (_context) {
947
947
  while (1) switch (_context.p = _context.n) {
948
948
  case 0:
@@ -989,7 +989,7 @@ var NewOverview = function NewOverview(_ref) {
989
989
  doc.text("PERFORMANCE REPORT", marginX, 50);
990
990
  doc.setTextColor(17, 24, 39);
991
991
  doc.setFontSize(13);
992
- doc.text("Dashboard overview - Overall", marginX, 72);
992
+ doc.text("Dashboard overview Overall", marginX, 72);
993
993
  doc.setFont("helvetica", "normal");
994
994
  doc.setFontSize(10);
995
995
  doc.setTextColor(107, 114, 128);
@@ -1057,12 +1057,17 @@ var NewOverview = function NewOverview(_ref) {
1057
1057
  avgGift = donorMixRaw.avgGift || 0;
1058
1058
  }
1059
1059
  activeCampaignRows = ((apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || []).map(function (campaign) {
1060
- 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))];
1060
+ 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"];
1061
1061
  });
1062
1062
  trafficRows = ((apiData === null || apiData === void 0 || (_apiData$trafficSourc = apiData.trafficSourceData) === null || _apiData$trafficSourc === void 0 ? void 0 : _apiData$trafficSourc.data) || []).map(function (item) {
1063
1063
  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))];
1064
1064
  });
1065
1065
  donorMixRows = [["New donors", "".concat(formatNumber(newDonorsCount))], ["Returning donors", "".concat(formatNumber(returningDonorsCount))], ["Avg gift", "$".concat(formatNumber(avgGift))]];
1066
+ recurringTotal = Number((apiData === null || apiData === void 0 || (_apiData$recurringBar = apiData.recurringBarChartData) === null || _apiData$recurringBar === void 0 ? void 0 : _apiData$recurringBar.recurringTotal) || 0);
1067
+ oneTimeTotalValue = Number((apiData === null || apiData === void 0 || (_apiData$recurringBar2 = apiData.recurringBarChartData) === null || _apiData$recurringBar2 === void 0 ? void 0 : _apiData$recurringBar2.oneTimeTotal) || 0);
1068
+ donorGeoRows = ((apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography) || []).slice(0, 6).map(function (item) {
1069
+ return [item.country || item.name || "-", "".concat(formatNumber(item.totalDonors || item.donors || 0)), "".concat(formatNumber(item.percentage || 0), "%")];
1070
+ });
1066
1071
  refundsData = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
1067
1072
  totalRaised = Number((overview === null || overview === void 0 ? void 0 : overview.totalRevenue) || 0);
1068
1073
  netRaised = Number((overview === null || overview === void 0 ? void 0 : overview.netRevenue) || 0);
@@ -1175,10 +1180,14 @@ var NewOverview = function NewOverview(_ref) {
1175
1180
  doc.setFontSize(9.5);
1176
1181
  doc.setTextColor(107, 114, 128);
1177
1182
  doc.text("Live fundraisers ranked by velocity", marginX, 126);
1183
+ doc.setTextColor(99, 102, 241);
1184
+ doc.text("View all →", pageWidth - marginX, 126, {
1185
+ align: "right"
1186
+ });
1178
1187
  autoTable(doc, {
1179
1188
  startY: 136,
1180
- head: [["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT"]],
1181
- body: activeCampaignRows.length ? activeCampaignRows : [["-", "$0", "0%", "0", "$0"]],
1189
+ head: [["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT", "STATUS"]],
1190
+ body: activeCampaignRows.length ? activeCampaignRows : [["-", "$0", "0%", "0", "$0", "-"]],
1182
1191
  margin: {
1183
1192
  left: marginX,
1184
1193
  right: marginX
@@ -1243,27 +1252,93 @@ var NewOverview = function NewOverview(_ref) {
1243
1252
  fillColor: [248, 250, 252]
1244
1253
  }
1245
1254
  });
1246
- 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))]];
1247
- autoTable(doc, {
1248
- startY: (((_doc$lastAutoTable2 = doc.lastAutoTable) === null || _doc$lastAutoTable2 === void 0 ? void 0 : _doc$lastAutoTable2.finalY) || donorCardTop + 120) + 12,
1249
- head: [["Additional Blocks", "Value"]],
1250
- body: miscRows,
1251
- margin: {
1252
- left: marginX,
1253
- right: marginX
1254
- },
1255
- styles: {
1256
- fontSize: 9,
1257
- cellPadding: 5
1258
- },
1259
- headStyles: {
1260
- fillColor: [241, 245, 249],
1261
- textColor: [51, 65, 85]
1262
- },
1263
- alternateRowStyles: {
1264
- fillColor: [248, 250, 252]
1265
- }
1255
+ cardsTop = (((_doc$lastAutoTable2 = doc.lastAutoTable) === null || _doc$lastAutoTable2 === void 0 ? void 0 : _doc$lastAutoTable2.finalY) || donorCardTop + 120) + 12;
1256
+ halfGap = 12;
1257
+ halfW = (contentWidth - halfGap) / 2;
1258
+ drawInfoCard = function drawInfoCard(_ref4) {
1259
+ var x = _ref4.x,
1260
+ y = _ref4.y,
1261
+ w = _ref4.w,
1262
+ h = _ref4.h,
1263
+ title = _ref4.title,
1264
+ subtitle = _ref4.subtitle,
1265
+ _ref4$lines = _ref4.lines,
1266
+ lines = _ref4$lines === void 0 ? [] : _ref4$lines;
1267
+ doc.setDrawColor(229, 231, 235);
1268
+ doc.roundedRect(x, y, w, h, 6, 6);
1269
+ doc.setFont("helvetica", "bold");
1270
+ doc.setTextColor(17, 24, 39);
1271
+ doc.setFontSize(10);
1272
+ doc.text(title, x + 10, y + 16);
1273
+ doc.setFont("helvetica", "normal");
1274
+ doc.setFontSize(8.5);
1275
+ doc.setTextColor(107, 114, 128);
1276
+ doc.text(subtitle, x + 10, y + 30);
1277
+ doc.setTextColor(55, 65, 81);
1278
+ lines.forEach(function (line, idx) {
1279
+ doc.text(line, x + 10, y + 46 + idx * 12, {
1280
+ maxWidth: w - 20
1281
+ });
1282
+ });
1283
+ };
1284
+ drawInfoCard({
1285
+ x: marginX,
1286
+ y: cardsTop,
1287
+ w: halfW,
1288
+ h: 86,
1289
+ title: "Recurring vs one-time",
1290
+ subtitle: "Donation type · weekly",
1291
+ lines: ["Recurring $".concat(formatNumber(recurringTotal)), "One-time $".concat(formatNumber(oneTimeTotalValue))]
1266
1292
  });
1293
+ drawInfoCard({
1294
+ x: marginX + halfW + halfGap,
1295
+ y: cardsTop,
1296
+ w: halfW,
1297
+ h: 86,
1298
+ title: "Refunds & chargebacks",
1299
+ subtitle: "Trust health · 30-day window",
1300
+ 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")]
1301
+ });
1302
+ drawInfoCard({
1303
+ x: marginX,
1304
+ y: cardsTop + 96,
1305
+ w: halfW,
1306
+ h: 88,
1307
+ title: "Order Bump",
1308
+ subtitle: "Revenue trend · last 30 days",
1309
+ 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))]
1310
+ });
1311
+ drawInfoCard({
1312
+ x: marginX + halfW + halfGap,
1313
+ y: cardsTop + 96,
1314
+ w: halfW,
1315
+ h: 88,
1316
+ title: "Upsell / Downsell / Referrals",
1317
+ subtitle: "Acceptance & raised",
1318
+ 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.")]
1319
+ });
1320
+ if (donorGeoRows.length > 0) {
1321
+ autoTable(doc, {
1322
+ startY: cardsTop + 192,
1323
+ head: [["COUNTRY", "DONORS", "SHARE"]],
1324
+ body: donorGeoRows,
1325
+ margin: {
1326
+ left: marginX,
1327
+ right: marginX
1328
+ },
1329
+ styles: {
1330
+ fontSize: 9,
1331
+ cellPadding: 4.5
1332
+ },
1333
+ headStyles: {
1334
+ fillColor: [241, 245, 249],
1335
+ textColor: [51, 65, 85]
1336
+ },
1337
+ alternateRowStyles: {
1338
+ fillColor: [248, 250, 252]
1339
+ }
1340
+ });
1341
+ }
1267
1342
  addFooter(2, 2);
1268
1343
  safeDate = new Date().toISOString().slice(0, 10);
1269
1344
  doc.save("DashboardOverview_report_".concat(safeDate, ".pdf"));