@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 +102 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +102 -25
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
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,
|
|
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, donorGeographyRaw, donorGeographyList, 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
|
|
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,19 @@ 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
|
+
donorGeographyRaw = apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography;
|
|
1067
|
+
donorGeographyList = Array.isArray(donorGeographyRaw) ? donorGeographyRaw : Array.isArray(donorGeographyRaw === null || donorGeographyRaw === void 0 ? void 0 : donorGeographyRaw.data) ? donorGeographyRaw.data : [];
|
|
1068
|
+
donorGeoRows = donorGeographyList.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
|
+
});
|
|
1064
1071
|
refundsData = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
|
|
1065
1072
|
totalRaised = Number((overview === null || overview === void 0 ? void 0 : overview.totalRevenue) || 0);
|
|
1066
1073
|
netRaised = Number((overview === null || overview === void 0 ? void 0 : overview.netRevenue) || 0);
|
|
@@ -1173,10 +1180,14 @@ var NewOverview = function NewOverview(_ref) {
|
|
|
1173
1180
|
doc.setFontSize(9.5);
|
|
1174
1181
|
doc.setTextColor(107, 114, 128);
|
|
1175
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
|
+
});
|
|
1176
1187
|
autoTable(doc, {
|
|
1177
1188
|
startY: 136,
|
|
1178
|
-
head: [["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT"]],
|
|
1179
|
-
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", "-"]],
|
|
1180
1191
|
margin: {
|
|
1181
1192
|
left: marginX,
|
|
1182
1193
|
right: marginX
|
|
@@ -1241,27 +1252,93 @@ var NewOverview = function NewOverview(_ref) {
|
|
|
1241
1252
|
fillColor: [248, 250, 252]
|
|
1242
1253
|
}
|
|
1243
1254
|
});
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
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))]
|
|
1264
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
|
+
}
|
|
1265
1342
|
addFooter(2, 2);
|
|
1266
1343
|
safeDate = new Date().toISOString().slice(0, 10);
|
|
1267
1344
|
doc.save("DashboardOverview_report_".concat(safeDate, ".pdf"));
|