Merge branch 'feature/dashboardUpdate' into otimizacao_relatorio_csv

pull/20/head
adriano 2022-08-18 12:19:42 -03:00
commit dc46e0cfc9
2 changed files with 58 additions and 53 deletions

View File

@ -207,9 +207,7 @@ const Dashboard = () => {
const classes = useStyles(); const classes = useStyles();
const [usersOnlineInfo, dispatch] = useReducer(reducer, []); const [usersOnlineInfo, dispatch] = useReducer(reducer, []);
const [ticketStatusChange, setStatus] = useState(); const [ticketStatusChange, setStatus] = useState();
const [open, setOpen] = useState(0); const [ticketsStatus, setTicktsStatus] = useState({ open: 0, openAll: 0, pending: 0, closed: 0 });
const [closed, setClosed] = useState(0);
const [pending, setPending] = useState(0);
const { user } = useContext(AuthContext); const { user } = useContext(AuthContext);
@ -296,25 +294,21 @@ const Dashboard = () => {
params: { status: "closed", date: dateToday }, params: { status: "closed", date: dateToday },
}); });
const _pending = await api.get("/tickets/count", { const _pending = await api.get("/tickets/count", {
params: { status: "pending", date: dateToday }, params: { status: "pending" },
}); });
const _openAll = await api.get("/tickets/count", { const _openAll = await api.get("/tickets/count", {
params: { status: "open" }, params: { status: "open" },
}); });
setTicktsStatus({
const _pendingAll = await api.get("/tickets/count", { open: _open.data.count,
params: { status: "pending"}, openAll: _openAll.data.count,
closed: _closed.data.count,
pending: _pending.data.count,
}); });
// setOpen(_open.data.count);
console.log('EM ATENDIMENTO TOTAL _openAll: ',_openAll.data) // setClosed(_closed.data.count);
console.log('AGUARDANDO TOTAL _pendingAll: ',_pendingAll.data) // setPending(_pending.data.count);
setOpen(_open.data.count);
setClosed(_closed.data.count);
setPending(_pending.data.count);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
@ -363,11 +357,11 @@ const Dashboard = () => {
variant="outlined" variant="outlined"
> >
<Typography component="h3" variant="h6" color="primary" paragraph> <Typography component="h3" variant="h6" color="primary" paragraph>
{i18n.t("dashboard.messages.inAttendance.title")} Aguardando
</Typography> </Typography>
<Grid item> <Grid item>
<Typography component="h1" variant="h4"> <Typography component="h1" variant="h4">
{open} {ticketsStatus.pending}
</Typography> </Typography>
</Grid> </Grid>
</Paper> </Paper>
@ -378,16 +372,19 @@ const Dashboard = () => {
style={{ overflow: "hidden" }} style={{ overflow: "hidden" }}
variant="outlined" variant="outlined"
> >
<Typography component="h3" variant="h6" color="primary" paragraph> <Typography component="h3" variant="h6" color="primary" style={{marginBottom:"0"}} paragraph>
{i18n.t("dashboard.messages.waiting.title")} Em Atendimento
</Typography> </Typography>
<Typography paragraph style={{fontSize: "12px", margin:"0px"}}>Hoje/Todo Periodo</Typography>
<Grid item> <Grid item>
<Typography component="h1" variant="h4"> <Typography component="h1" variant="h4">
{pending} {ticketsStatus.open}/{ticketsStatus.openAll}
</Typography> </Typography>
</Grid> </Grid>
</Paper> </Paper>
</Grid> </Grid>
<Grid item xs={12} sm={6} md={6} lg={4}> <Grid item xs={12} sm={6} md={6} lg={4}>
<Paper <Paper
className={classes.customFixedHeightPaper} className={classes.customFixedHeightPaper}
@ -395,11 +392,11 @@ const Dashboard = () => {
variant="outlined" variant="outlined"
> >
<Typography component="h3" variant="h6" color="primary" paragraph> <Typography component="h3" variant="h6" color="primary" paragraph>
{i18n.t("dashboard.messages.closed.title")} Fechados
</Typography> </Typography>
<Grid item> <Grid item>
<Typography component="h1" variant="h4"> <Typography component="h1" variant="h4">
{closed} {ticketsStatus.closed}
</Typography> </Typography>
</Grid> </Grid>
</Paper> </Paper>

View File

@ -18,7 +18,7 @@ import MaterialTable from 'material-table';
import LogoutIcon from '@material-ui/icons/CancelOutlined'; import LogoutIcon from '@material-ui/icons/CancelOutlined';
import { CSVLink } from "react-csv"; import { CSVLink } from "react-csv";
@ -474,10 +474,10 @@ const Report = () => {
setProfile('user') setProfile('user')
} }
}, [reportOption]) }, [reportOption])
const handleCSVMessages = () => {
const handleCSVMessages = () => {
const fetchQueries = async () => { const fetchQueries = async () => {
@ -485,7 +485,7 @@ const Report = () => {
const dataQuery = await api.get("/reports/messages", { params: { userId, startDate, endDate }, }); const dataQuery = await api.get("/reports/messages", { params: { userId, startDate, endDate }, });
console.log('dataQuery messages: ', dataQuery.data) console.log('dataQuery messages: ', dataQuery.data)
if (dataQuery.data.length > 0) { if (dataQuery.data.length > 0) {
@ -498,11 +498,11 @@ const Report = () => {
else { else {
dataCSVFormat[i].fromMe = 'Cliente' dataCSVFormat[i].fromMe = 'Cliente'
} }
} }
setDataCSV(dataCSVFormat) setDataCSV(dataCSVFormat)
setIsMount(false); setIsMount(false);
} }
} catch (err) { } catch (err) {
console.log(err); console.log(err);
@ -536,10 +536,10 @@ const Report = () => {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL); const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
socket.on("onlineStatus", (data) => { socket.on("onlineStatus", (data) => {
let date = new Date().toLocaleDateString('pt-BR').split('/') let date = new Date().toLocaleDateString('pt-BR').split('/')
let dateToday = `${date[2]}-${date[1]}-${date[0]}` let dateToday = `${date[2]}-${date[1]}-${date[0]}`
if (data.action === "logout" || (data.action === "update" && if (data.action === "logout" || (data.action === "update" &&
((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) { ((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
@ -551,7 +551,7 @@ const Report = () => {
} }
else if (data.action === "delete") { else if (data.action === "delete") {
dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime }); dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime });
} }
}); });
@ -599,8 +599,8 @@ const Report = () => {
// ))) // )))
// } // }
setData(query.map((column) => { return { ...column } })) setData(query.map((column) => { return { ...column } }))
}, [query]) }, [query])
@ -632,7 +632,7 @@ const Report = () => {
// ' | clientHeight: ', clientHeight, // ' | clientHeight: ', clientHeight,
// ' | scrollHeight - (scrollTop + 1): ', scrollHeight - (scrollTop + 1)) // ' | scrollHeight - (scrollTop + 1): ', scrollHeight - (scrollTop + 1))
if (scrollHeight - (scrollTop + 1) < clientHeight) { if (scrollHeight - (scrollTop + 1) < clientHeight) {
loadMore(); loadMore();
@ -667,30 +667,38 @@ const Report = () => {
{reportOption === '1' && {reportOption === '1' &&
<div> <div>
<Button style={{display: "none"}} {/* <Button style={{ display: "none" }}
variant="contained" variant="contained"
color="primary" color="primary"
onClick={(e) => { onClick={(e) => {
handleCSVMessages() handleCSVMessages()
}} }}
> > */}
{"CSV ALL"}
</Button>
<div> {/* <Button
<CSVLink variant="contained"
data={dataCSV} color="primary"
headers={columns} onClick={(e) => {
filename={'Relatorio_detalhado_atendimento_atendentes.csv'} handleCSVMessages()
target={'_blank'} }}
ref={csvLink} /> >
</div> {"CSV ALL"}
</Button> */}
<div>
<CSVLink
data={dataCSV}
headers={columns}
filename={'Relatorio_detalhado_atendimento_atendentes.csv'}
target={'_blank'}
ref={csvLink} />
</div>
</div> </div>
} }
</Item> </Item>
</Box> </Box>