fixed status tickets by request

plus, fixed usestate calls in tickets
pull/20/head
RenatoDiGiacomo 2022-08-16 16:33:40 -03:00
parent 579cb680fb
commit aaf15a1847
1 changed files with 20 additions and 23 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>