Skip to content

Commit

Permalink
add report in student list
Browse files Browse the repository at this point in the history
  • Loading branch information
TI JONNY committed Jan 6, 2025
1 parent 8efaae3 commit 4769808
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions src/Pages/Student/StudentList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import BeneficiariesListProvider, {
} from "../../../Context/Beneficiaries/BeneficiariesList/context";
import { BeneficiariesListType } from "../../../Context/Beneficiaries/BeneficiariesList/type";
import color from "../../../Styles/colors";
import { Padding } from "../../../Styles/styles";
import { Padding, Row } from "../../../Styles/styles";
import { formatarData } from "../../../Controller/controllerGlobal";
import http from "../../../Services/axios";

const BeneficiariesList = () => {
return (
Expand Down Expand Up @@ -49,30 +50,41 @@ const BeneficiariesListPage = () => {
);
};

// const ActionBeneficiariesBody = (rowData: any) => {
// return (
// <Row id="center" style={{ gap: "8px" }}>
// <Button
// rounded
// icon={"pi pi-pencil"}
// onClick={() => {
// history(`${rowData.id}`);
// }}
// />
// <Button
// severity="danger"
// rounded
// icon={"pi pi-trash"}
// onClick={() => {
// setVisible(rowData);
// }}
// />
// </Row>
// );
// };
const downloadCSV = async (row: any) => {

try {
const response = await http.get('/performance/report-one-line-student/' + row.id)

// Criar um link para download
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'synapse-' + row.name + '.csv'); // Nome do arquivo
document.body.appendChild(link);
link.click();

// Remover o link
} catch (error) {
console.error('Erro ao baixar o arquivo:', error);
}
};

const ActionBeneficiariesBody = (rowData: any) => {
return (
<Row id="center" style={{ gap: "8px" }}>
<Button
rounded
icon={"pi pi-download"}
onClick={() => {
downloadCSV(rowData);
}}
/>
</Row>
);
};

const BodyCreated = (value: any) => {
return(
return (
<p>
{formatarData(value.created_at)}
</p>
Expand All @@ -98,7 +110,7 @@ const BeneficiariesListPage = () => {
header="Nome"
></Column>
<Column body={BodyCreated} header="Data de criação"></Column>
{/* <Column header="Ações" body={ActionBeneficiariesBody}></Column> */}
<Column header="Ações" body={ActionBeneficiariesBody}></Column>
</DataTable>
</ContentPage>
<ConfirmDialog
Expand Down

0 comments on commit 4769808

Please sign in to comment.