Alteração no botao download csv

pull/20/head
adriano 2022-09-06 01:09:52 -03:00
parent 55e83ff8fc
commit 0e720ef48e
1 changed files with 20 additions and 8 deletions

View File

@ -22,6 +22,7 @@ import fileDownload from 'js-file-download'
import openSocket from "socket.io-client";
import { TramOutlined } from "@material-ui/icons";
const report = [{ 'value': '1', 'label': 'Atendimento por atendentes' }, { 'value': '2', 'label': 'Usuários online/offline' }]
@ -252,6 +253,7 @@ const Report = () => {
useEffect(() => {
dispatch({ type: "RESET" });
dispatchQ({ type: "RESET" })
@ -419,23 +421,27 @@ const Report = () => {
const handleCSVDownload = async () => {
setOnQueueProcessStatus('downloading')
try {
let res = await apiBroker.get(`/reports/download/${csvFile}`, { responseType: 'blob' });
if (res) {
fileDownload(res.data, `${csvFile}`);
setOnQueueProcessStatus('empty')
}
} catch (err) {
console.log(err);
}
}
const handleCSVMessages = () => {
const fetchQueries = async () => {
@ -601,12 +607,18 @@ const Report = () => {
variant="contained"
color="primary"
onClick={(e) => {
handleCSVDownload()
handleCSVDownload(e)
}}
>
{"CSV DOWNLOAD"}
{'CSV DOWNLOAD'}
</Button>
</>);
case 'downloading':
return (
<>
<span>DOWNLOADING...</span>
</>);
default:
return (<><span>WAITING...</span></>);