Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/components/ExportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useMemo, useState } from "react";
import { useSession } from "next-auth/react";
import jsPDF from "jspdf";
import autoTable from "jspdf-autotable";
import { toast } from "sonner";

interface PRData {
open: number;
Expand Down Expand Up @@ -297,9 +298,9 @@ export default function ExportButton() {
.sort(([a], [b]) => a.localeCompare(b))
.map(([day, commits]) => ({ day, commits: commits as number }));

return {
prData,
contribData,
return {
prData,
contribData,
goalsData: goalsData?.goals as Goal[],
dbExportData
};
Expand Down Expand Up @@ -404,6 +405,13 @@ export default function ExportButton() {
]);

downloadFile(csv, "dashboard-metrics.csv", "text/csv");
toast.success("CSV exported successfully.");
} catch (error) {
console.error("CSV export failed:", error);

toast.error(
"Failed to export CSV. Please try again."
);
} finally {
setIsExportingCSV(false);
}
Expand Down Expand Up @@ -658,7 +666,15 @@ export default function ExportButton() {
addFooter(doc, generatedAt);

doc.save(`devtrack-export-${reportName || "metrics"}-${new Date().toISOString().slice(0, 10)}.pdf`);
} finally {
toast.success("PDF exported successfully.");
} catch (error) {
console.error("PDF export failed:", error);

toast.error(
"Failed to export PDF. Please try again."
);
}
finally {
setIsExportingPDF(false);
}
};
Expand All @@ -668,7 +684,7 @@ export default function ExportButton() {
try {
const { prData, goalsData, contribData, dbExportData } = await fetchData();
const generatedAt = formatGeneratedTimestamp();

const jsonData = {
generatedAt,
githubUser: reportName || "unknown",
Expand Down
Loading