This commit is contained in:
Alex Santos 2022-06-28 16:16:04 -03:00
parent d880d2ddc9
commit 843da7c933
2 changed files with 22 additions and 5 deletions

View File

@ -8,7 +8,7 @@ import PageTitle from '../../../components/pageTitle/PageTitle'
import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView' import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView'
import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload'; import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload';
import { api } from '../../../services/api' import { api } from '../../../services/api'
import PdfThumbnail from 'react-pdf-thumbnail'; // import PdfThumbnail from 'react-pdf-thumbnail';
import FormData from 'form-data'; import FormData from 'form-data';
@ -58,12 +58,12 @@ export default function industryInfo({userName}: any) {
<IndustryInfoView> <IndustryInfoView>
<Snackbar open={openSnackSuccess} autoHideDuration={4000} onClose={handleCloseSnack}> <Snackbar open={openSnackSuccess} autoHideDuration={4000} onClose={handleCloseSnack}>
<Alert onClose={handleCloseSnack} severity="success" sx={{ width: '100%' }}> <Alert onClose={handleCloseSnack} severity="success" sx={{ width: '100%' }}>
PDF Baixado com Sucesso! PDF enviado com Sucesso!
</Alert> </Alert>
</Snackbar> </Snackbar>
<Snackbar open={openSnackError} autoHideDuration={4000} onClose={handleCloseSnack}> <Snackbar open={openSnackError} autoHideDuration={4000} onClose={handleCloseSnack}>
<Alert onClose={handleCloseSnack} severity="error" sx={{ width: '100%' }}> <Alert onClose={handleCloseSnack} severity="error" sx={{ width: '100%' }}>
PDF não baixado! Falha ao enviar PDF!
</Alert> </Alert>
</Snackbar> </Snackbar>
<Head> <Head>

View File

@ -36,8 +36,24 @@ export default function ResumoOperacao({tableData, clientsData, userName, client
setUnidade(event.target.value); setUnidade(event.target.value);
}; };
function stringToBytes(text) {
const length = text.length;
const result = new Uint8Array(length);
for (let i = 0; i < length; i++) {
const code = text.charCodeAt(i);
const byte = code > 255 ? 32 : code;
result[i] = byte;
}
return result;
}
// const originalString = 'ååå';
// const bytes = stringToBytes(originalString);
// const blob = new Blob([bytes.buffer], { type: 'text/plain; charset=ISO-8859-1' });
function downloadCSVFile(csv, filename) { function downloadCSVFile(csv, filename) {
const csv_file = new Blob([csv], {type: "text/csv"});
const csv_file = new Blob(["\ufeff",csv], {type: "text/csv"});
const download_link = document.createElement("a"); const download_link = document.createElement("a");
@ -63,7 +79,8 @@ export default function ResumoOperacao({tableData, clientsData, userName, client
row.push(cols[j].innerText); row.push(cols[j].innerText);
} }
data.push(row.join(","));
data.push(row.join(";"));
} }
downloadCSVFile(data.join("\n"), filename); downloadCSVFile(data.join("\n"), filename);