Remoção de console.log e desable do botao csv export

pull/20/head
adriano 2022-08-29 10:55:07 -03:00
parent 46c9119195
commit 118fa7398d
2 changed files with 58 additions and 252 deletions

View File

@ -20,19 +20,16 @@ const MTable = (props) => {
const [selectedRow, setSelectedRow] = useState(null);
//const dataLoad = props.data.map((dt) => { return { ...dt }});
const dataLoad = props.data.map(({ user, ...others }) => ({ ...others, 'user': user ? user : { name: 'Aguardando atendente', email: '' } }));
const columnsLoad = props.columns.map((column) => { return { ...column } });
useEffect(() => {
// useEffect(() => {
console.log(`You have clicked the button ${selectedRow} times`)
// console.log(`You have clicked the button ${selectedRow} times`)
// console.log('TABLE REF: ', tableRef)
}, [selectedRow]);
// }, [selectedRow]);
useEffect(() => {
@ -77,9 +74,6 @@ const MTable = (props) => {
return
}
console.log(selectedRow.tableData.id);
console.log(selectedRow);
console.log(selectedRow.messages);
setSelectedRow(selectedRow.tableData.id)
if (props.hasChild) {
@ -90,7 +84,6 @@ const MTable = (props) => {
clientContactNumber={selectedRow.contact.number} />)
}
console.log('props.hasChild: ', props.hasChild)
//evt.stopPropagation()
}

View File

@ -1,8 +1,7 @@
import React, { useState, useEffect, useReducer, useContext, useRef } from "react";
import React, { useState, useEffect, useReducer, useContext } from "react";
import MainContainer from "../../components/MainContainer";
import api from "../../services/api";
import SelectField from "../../components/Report/SelectField";
//import { data } from '../../components/Report/MTable/data';
import DatePicker1 from '../../components/Report/DatePicker'
import DatePicker2 from '../../components/Report/DatePicker'
import MTable from "../../components/Report/MTable";
@ -22,82 +21,10 @@ import apiBroker from "../../services/apiBroker";
import fileDownload from 'js-file-download'
import fs from 'fs'
import { CSVLink } from "react-csv";
// import CircularProgress from '@mui/material/CircularProgress';
import openSocket from "socket.io-client";
import { set } from "date-fns";
const report = [{ 'value': '1', 'label': 'Atendimento por atendentes' }, { 'value': '2', 'label': 'Usuários online/offline' }]
let columns = [
{
key: 'ticket.whatsapp.name',
label: 'Loja',
},
{
key: 'id',
label: 'id Mensagem',
},
{
key: 'ticket.id',
label: 'id Conversa',
},
{
key: 'ticket.contact.name',
label: 'Cliente',
},
{
key: 'ticket.user.name',
label: 'Atendente',
},
{
key: 'body',
label: 'Mensagem',
},
{
key: 'fromMe',
label: 'Sentido',
},
{
key: 'createdAt',
label: 'Criada',
},
{
key: 'ticket.contact.number',
label: 'Telefone cliente',
},
{
key: 'ticket.queue.name',
label: 'Fila',
},
{
key: 'ticket.status',
label: 'Status',
},
{
key: 'ticket.statusChatEnd',
label: 'Status de encerramento',
}
]
//
const reducerQ = (state, action) => {
@ -105,12 +32,8 @@ const reducerQ = (state, action) => {
const userId = action.payload;
//console.log('Entrou no delete user status userId: ', userId)
const userIndex = state.findIndex((u) => `${u.id}` === `${userId}`);
// console.log('>>>>>>>>>>>>>>>>>>>>> userIndex: ', userIndex)
if (userIndex !== -1) {
state.splice(userIndex, 1);
}
@ -147,8 +70,6 @@ const reducerQ = (state, action) => {
let onlineUser = action.payload
let index = -1
// console.log('sssssssssstate: ', state, ' | ONLINE USERS: onlineUser.userId ', onlineUser.userId)
if (onlineUser.sumOpen || onlineUser.sumClosed) {
index = state.findIndex((e) => ((onlineUser.sumOpen && e.id === onlineUser.sumOpen.userId) || (onlineUser.sumClosed && e.id === onlineUser.sumClosed.userId)))
}
@ -156,15 +77,9 @@ const reducerQ = (state, action) => {
index = state.findIndex((e) => `${e.id}` === `${onlineUser.userId}`)
}
//console.log(' *********************** index: ', index)
if (index !== -1) {
// console.log('ENTROU NO INDEX')
if (!("statusOnline" in state[index])) {
state[index].statusOnline = onlineUser
}
@ -187,10 +102,8 @@ const reducerQ = (state, action) => {
if (onlineUser.sumOpen) {
if ("sumOpen" in state[index]) {
// console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1 | state[index].sumOpen["count"]: ', state[index].sumOpen['count'], ' | onlineUser.sumOpen.count: ', onlineUser.sumOpen.count)
state[index].sumOpen['count'] = onlineUser.sumOpen.count
} else if (!("sumOpen" in state[index])) {
// console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1')
state[index].sumOpen = onlineUser.sumOpen
}
@ -199,10 +112,8 @@ const reducerQ = (state, action) => {
if (onlineUser.sumClosed) {
if ("sumClosed" in state[index]) {
// console.log(' >>>>>>>>>>>>>>>>>> sumClosed 1 | state[index].sumClosed["count"]: ', state[index].sumClosed['count'], ' | onlineUser.sumClosed.count: ', onlineUser.sumClosed.count)
state[index].sumClosed['count'] = onlineUser.sumClosed.count
} else if (!("sumClosed" in state[index])) {
// console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1')
state[index].sumClosed = onlineUser.sumClosed
}
@ -310,9 +221,6 @@ let columnsData = [
const Report = () => {
const csvLink = useRef()
const { user: userA } = useContext(AuthContext);
//--------
@ -327,14 +235,11 @@ const Report = () => {
const [pageNumber, setPageNumber] = useState(1);
const [users, dispatch] = useReducer(reducer, []);
//const [columns, setColums] = useState([])
const [startDate, setDatePicker1] = useState(new Date())
const [endDate, setDatePicker2] = useState(new Date())
const [userId, setUser] = useState(null)
const [query, dispatchQ] = useReducer(reducerQ, [])
const [dataCSV, setDataCSV] = useState([])
const [isMount, setIsMount] = useState(true);
const [reportOption, setReport] = useState('1')
const [reporList,] = useState(report)
@ -364,17 +269,13 @@ const Report = () => {
const fetchUsers = async () => {
try {
//console.log('profile: ', profile)
const { data } = await api.get("/users/", {
params: { searchParam, pageNumber, profile },
});
dispatch({ type: "LOAD_USERS", payload: data.users });
//setHasMore(data.hasMore);
//setLoading(false);
} catch (err) {
console.log(err);
}
@ -402,10 +303,6 @@ const Report = () => {
const { data } = await api.get("/reports/", { params: { userId, startDate, endDate, pageNumber: pageNumberTickets }, });
// console.log('dataQuery: ', data)
// console.log('pageNumberTickets: ', pageNumberTickets)
// dispatchQ({ type: "RESET" })
dispatchQ({ type: "LOAD_QUERY", payload: data.tickets });
setHasMore(data.hasMore);
@ -467,7 +364,6 @@ const Report = () => {
setReport(data)
// console.log(' data: ', data)
}
useEffect(() => {
@ -507,9 +403,6 @@ const Report = () => {
setOnQueueProcessStatus('empty')
}
console.log('>>>>> queryOnqueue: ', queryOnQueue.data)
} catch (err) {
console.log(err);
@ -521,7 +414,7 @@ const Report = () => {
}, 500);
return () => clearTimeout(delayDebounceFn);
}, [])
}, [ userA ])
const handleCSVDownload = async () => {
@ -566,20 +459,10 @@ const Report = () => {
}
});
console.log('dataQuery messages: ', querySavedOnQueue.data.queueStatus)
const onQueueStatus = querySavedOnQueue.data.queueStatus
setOnQueueProcessStatus(onQueueStatus)
// if (onQueueStatus.data.length > 0) {
// let dataCSVFormat = queueStatus.data;
// setIsMount(false);
// }
} catch (err) {
console.log(err);
}
@ -591,21 +474,6 @@ const Report = () => {
useEffect(() => {
if (isMount) {
return;
}
csvLink.current.link.click()
}, [dataCSV, isMount, csvLink]);
useEffect(() => {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
@ -625,7 +493,6 @@ const Report = () => {
if (reportOption === '2') {
// const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
socket.on("onlineStatus", (data) => {
@ -635,8 +502,6 @@ const Report = () => {
if (data.action === "logout" || (data.action === "update" &&
((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
//console.log('UPDATE FROM ONLINE/OFFLINE LOGED USERS: ', data.userOnlineTime, ' | data.action : ', data.action)
dispatchQ({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime });
}
@ -649,16 +514,11 @@ const Report = () => {
socket.on("user", (data) => {
if (data.action === "delete") {
// console.log(' entrou no delete user: ', data)
dispatch({ type: "DELETE_USER", payload: +data.userId });
}
});
// return () => {
// socket.disconnect();
// };
}
else if (reportOption === "1") {
dispatchQ({ type: "RESET" })
@ -670,31 +530,11 @@ const Report = () => {
};
}, [reportOption, startDate, endDate, userId]);
// const handleDeleteRows = (id) => {
// let _data = [...dataRows];
// _data.forEach(rd => {
// _data = _data.filter(t => t.id !== id);
// });
// setData(_data);
// };
}, [reportOption, startDate, endDate, userId, userA]);
useEffect(() => {
//if (!loading) {
// setData(query.map(({ scheduleReminder, ...others }) => (
// { ...others, 'scheduleReminder': `${others.statusChatEndId}` === '3' ? 'Agendamento' : 'Lembrete' }
// )))
// }
setData(query.map((column) => { return { ...column } }))
@ -723,16 +563,10 @@ const Report = () => {
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
// console.log('scrollTop: ', scrollTop,
// ' | scrollHeight: ', scrollHeight,
// ' | clientHeight: ', clientHeight,
// ' | scrollHeight - (scrollTop + 1): ', scrollHeight - (scrollTop + 1))
if (scrollHeight - (scrollTop + 1) < clientHeight) {
loadMore();
// e.currentTarget.scrollTo(0, 200);
}
};
@ -743,6 +577,7 @@ const Report = () => {
return (
<>
<Button
disabled={query && query.length > 0 ? false : true}
variant="contained"
color="primary"
onClick={(e) => {
@ -769,7 +604,7 @@ const Report = () => {
handleCSVDownload()
}}
>
{"DOWNLOAD"}
{"CSV DOWNLOAD"}
</Button>
</>);
@ -822,9 +657,6 @@ const Report = () => {
{reportOption === '1' &&
// <div onScroll={handleScroll} style={{ height: 400, overflowY: "scroll" }}>
// </div>
<>
<MTable data={query}
@ -894,7 +726,6 @@ const Report = () => {
]
}
data={dataRows}
// icons={tableIcons}
actions={[
(rowData) => {
@ -909,8 +740,6 @@ const Report = () => {
tooltip: 'deslogar',
disable: false,
onClick: (event, rowData) => {
// console.log(' ROW DATA INFO: ', rowData, ' | rowData: ', rowData.id)
handleLogouOnlineUser(rowData.id)
}
}
@ -928,7 +757,6 @@ const Report = () => {
paging: false,
padding: 'dense',
sorting: true,
//loadingType: 'linear',
searchFieldStyle: {
width: 300,
},
@ -944,21 +772,6 @@ const Report = () => {
fontSize: 14,
}
// cellStyle: (rowData) => {
// return {
// fontSize: 12,
// color: "#fff",
// };
// }
}}
/>