Skip to content

Commit

Permalink
Merge pull request #31 from Nucleo-Estudantes-Informatica-ISEP/dev
Browse files Browse the repository at this point in the history
Hotfix: build error
  • Loading branch information
esfoliante authored Nov 25, 2024
2 parents a50b5c6 + d364540 commit b5d43f0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/components/ExcelButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ import Spinner from "../Spinner";

import download from "downloadjs";

interface SavedStudent {
id: string;
studentId: string;
isSaved: boolean;
createdAt: Date;
student: {
name: string;
user: {
email: string;
};
};
}

interface ExcelButtonProps {
className?: string;
data: any[];
data: SavedStudent[];
}

const ExcelButton: React.FC<ExcelButtonProps> = ({
Expand All @@ -20,7 +33,7 @@ const ExcelButton: React.FC<ExcelButtonProps> = ({
const handleDownload = async () => {
if (isLoading) return;
setIsLoading(true);
data = data.map((scan) => {
const dataJSON = data.map((scan) => {
return {
id: scan.id,
studentId: scan.studentId,
Expand All @@ -29,7 +42,7 @@ const ExcelButton: React.FC<ExcelButtonProps> = ({
createdAt: scan.createdAt.toLocaleString(),
};
});
const worksheet = XLSX.utils.json_to_sheet(data);
const worksheet = XLSX.utils.json_to_sheet(dataJSON);

const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
Expand Down

0 comments on commit b5d43f0

Please sign in to comment.