@ammarkhalidfarooq/dashboard-package 0.5.13 → 0.5.15

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, donorGeographyRaw, donorGeographyList, 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,19 @@ 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
+ donorGeographyRaw = apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography;
1069
+ donorGeographyList = Array.isArray(donorGeographyRaw) ? donorGeographyRaw : Array.isArray(donorGeographyRaw === null || donorGeographyRaw === void 0 ? void 0 : donorGeographyRaw.data) ? donorGeographyRaw.data : [];
1070
+ donorGeoRows = donorGeographyList.slice(0, 6).map(function (item) {
1071
+ return [item.country || item.name || "-", "".concat(formatNumber(item.totalDonors || item.donors || 0)), "".concat(formatNumber(item.percentage || 0), "%")];
1072
+ });
1066
1073
  refundsData = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
1067
1074
  totalRaised = Number((overview === null || overview === void 0 ? void 0 : overview.totalRevenue) || 0);
1068
1075
  netRaised = Number((overview === null || overview === void 0 ? void 0 : overview.netRevenue) || 0);
@@ -1175,10 +1182,14 @@ var NewOverview = function NewOverview(_ref) {
1175
1182
  doc.setFontSize(9.5);
1176
1183
  doc.setTextColor(107, 114, 128);
1177
1184
  doc.text("Live fundraisers ranked by velocity", marginX, 126);
1185
+ doc.setTextColor(99, 102, 241);
1186
+ doc.text("View all →", pageWidth - marginX, 126, {
1187
+ align: "right"
1188
+ });
1178
1189
  autoTable(doc, {
1179
1190
  startY: 136,
1180
- head: [["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT"]],
1181
- body: activeCampaignRows.length ? activeCampaignRows : [["-", "$0", "0%", "0", "$0"]],
1191
+ head: [["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT", "STATUS"]],
1192
+ body: activeCampaignRows.length ? activeCampaignRows : [["-", "$0", "0%", "0", "$0", "-"]],
1182
1193
  margin: {
1183
1194
  left: marginX,
1184
1195
  right: marginX
@@ -1243,27 +1254,93 @@ var NewOverview = function NewOverview(_ref) {
1243
1254
  fillColor: [248, 250, 252]
1244
1255
  }
1245
1256
  });
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
- }
1257
+ cardsTop = (((_doc$lastAutoTable2 = doc.lastAutoTable) === null || _doc$lastAutoTable2 === void 0 ? void 0 : _doc$lastAutoTable2.finalY) || donorCardTop + 120) + 12;
1258
+ halfGap = 12;
1259
+ halfW = (contentWidth - halfGap) / 2;
1260
+ drawInfoCard = function drawInfoCard(_ref4) {
1261
+ var x = _ref4.x,
1262
+ y = _ref4.y,
1263
+ w = _ref4.w,
1264
+ h = _ref4.h,
1265
+ title = _ref4.title,
1266
+ subtitle = _ref4.subtitle,
1267
+ _ref4$lines = _ref4.lines,
1268
+ lines = _ref4$lines === void 0 ? [] : _ref4$lines;
1269
+ doc.setDrawColor(229, 231, 235);
1270
+ doc.roundedRect(x, y, w, h, 6, 6);
1271
+ doc.setFont("helvetica", "bold");
1272
+ doc.setTextColor(17, 24, 39);
1273
+ doc.setFontSize(10);
1274
+ doc.text(title, x + 10, y + 16);
1275
+ doc.setFont("helvetica", "normal");
1276
+ doc.setFontSize(8.5);
1277
+ doc.setTextColor(107, 114, 128);
1278
+ doc.text(subtitle, x + 10, y + 30);
1279
+ doc.setTextColor(55, 65, 81);
1280
+ lines.forEach(function (line, idx) {
1281
+ doc.text(line, x + 10, y + 46 + idx * 12, {
1282
+ maxWidth: w - 20
1283
+ });
1284
+ });
1285
+ };
1286
+ drawInfoCard({
1287
+ x: marginX,
1288
+ y: cardsTop,
1289
+ w: halfW,
1290
+ h: 86,
1291
+ title: "Recurring vs one-time",
1292
+ subtitle: "Donation type · weekly",
1293
+ lines: ["Recurring $".concat(formatNumber(recurringTotal)), "One-time $".concat(formatNumber(oneTimeTotalValue))]
1266
1294
  });
1295
+ drawInfoCard({
1296
+ x: marginX + halfW + halfGap,
1297
+ y: cardsTop,
1298
+ w: halfW,
1299
+ h: 86,
1300
+ title: "Refunds & chargebacks",
1301
+ subtitle: "Trust health · 30-day window",
1302
+ 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")]
1303
+ });
1304
+ drawInfoCard({
1305
+ x: marginX,
1306
+ y: cardsTop + 96,
1307
+ w: halfW,
1308
+ h: 88,
1309
+ title: "Order Bump",
1310
+ subtitle: "Revenue trend · last 30 days",
1311
+ 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))]
1312
+ });
1313
+ drawInfoCard({
1314
+ x: marginX + halfW + halfGap,
1315
+ y: cardsTop + 96,
1316
+ w: halfW,
1317
+ h: 88,
1318
+ title: "Upsell / Downsell / Referrals",
1319
+ subtitle: "Acceptance & raised",
1320
+ 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.")]
1321
+ });
1322
+ if (donorGeoRows.length > 0) {
1323
+ autoTable(doc, {
1324
+ startY: cardsTop + 192,
1325
+ head: [["COUNTRY", "DONORS", "SHARE"]],
1326
+ body: donorGeoRows,
1327
+ margin: {
1328
+ left: marginX,
1329
+ right: marginX
1330
+ },
1331
+ styles: {
1332
+ fontSize: 9,
1333
+ cellPadding: 4.5
1334
+ },
1335
+ headStyles: {
1336
+ fillColor: [241, 245, 249],
1337
+ textColor: [51, 65, 85]
1338
+ },
1339
+ alternateRowStyles: {
1340
+ fillColor: [248, 250, 252]
1341
+ }
1342
+ });
1343
+ }
1267
1344
  addFooter(2, 2);
1268
1345
  safeDate = new Date().toISOString().slice(0, 10);
1269
1346
  doc.save("DashboardOverview_report_".concat(safeDate, ".pdf"));