Completed merge and fixed errors
parent
992bdf8deb
commit
0f7e91c1bd
|
@ -67,7 +67,7 @@ export const initWbot = async (whatsapp: Whatsapp, backupSessionRestore: boolean
|
|||
// usando instancia do chrome
|
||||
const wbot: Session = new Client({
|
||||
session: sessionCfg, authStrategy: new LocalAuth({ clientId: 'bd_' + whatsapp.id }),
|
||||
puppeteer: { args: ['--no-sandbox', '--disable-setuid-sandbox'], executablePath: process.env.CHROME_BIN || '/usr/bin/google-chrome-stable' },
|
||||
puppeteer: { args: ['--no-sandbox', '--disable-setuid-sandbox'], executablePath: process.env.CHROME_BIN || undefined },
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useContext, useReducer, useEffect } from "react";
|
||||
import React, { useContext, useReducer, useEffect, useState } from "react";
|
||||
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import Container from "@material-ui/core/Container";
|
||||
|
@ -172,43 +172,33 @@ const reducer = (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;
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineUser.sumOpen) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(onlineUser.openClosedInQueue){
|
||||
state[index].openClosedInQueue = onlineUser.openClosedInQueue
|
||||
}
|
||||
if (onlineUser.openClosedInQueue) {
|
||||
state[index].openClosedInQueue = onlineUser.openClosedInQueue;
|
||||
}
|
||||
if (onlineUser.openClosedOutQueue) {
|
||||
state[index].openClosedOutQueue = onlineUser.openClosedOutQueue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return [...state];
|
||||
}
|
||||
|
@ -219,151 +209,120 @@ const reducer = (state, action) => {
|
|||
};
|
||||
|
||||
const Dashboard = () => {
|
||||
const classes = useStyles()
|
||||
const [usersOnlineInfo, dispatch] = useReducer(reducer, [])
|
||||
const classes = useStyles();
|
||||
const [usersOnlineInfo, dispatch] = useReducer(reducer, []);
|
||||
const [ticketStatusChange, setStatus] = useState();
|
||||
const [open, setOpen] = useState(0);
|
||||
const [closed, setClosed] = useState(0);
|
||||
const [pending, setPending] = useState(0);
|
||||
|
||||
const [open, setOpen] = useState(0)
|
||||
const [closed, setClosed] = useState(0)
|
||||
const [pending, setPending] = useState(0)
|
||||
const { user } = useContext(AuthContext);
|
||||
|
||||
const { user } = useContext(AuthContext);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch({ type: "RESET" });
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleLogouOnlineUser = async (userId) => {
|
||||
try {
|
||||
await api.get(`/users/logout/${userId}`);
|
||||
//toast.success(("Desloged!"));
|
||||
//handleDeleteRows(scheduleId)
|
||||
} catch (err) {
|
||||
// toastError(err);
|
||||
}
|
||||
};
|
||||
|
||||
dispatch({ type: "RESET" });
|
||||
useEffect(() => {
|
||||
//setLoading(true);
|
||||
|
||||
}, []);
|
||||
const delayDebounceFn = setTimeout(() => {
|
||||
// setLoading(true);
|
||||
const fetchQueries = async () => {
|
||||
try {
|
||||
let date = new Date().toLocaleDateString("pt-BR").split("/");
|
||||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`;
|
||||
|
||||
const dataQuery = await api.get("/reports/user/services", {
|
||||
params: { userId: null, startDate: dateToday, endDate: dateToday },
|
||||
});
|
||||
dispatch({ type: "RESET" });
|
||||
dispatch({ type: "LOAD_QUERY", payload: dataQuery.data });
|
||||
|
||||
console.log("xxx REPORT 2 dataQuery : ", dataQuery.data);
|
||||
|
||||
//console.log()
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogouOnlineUser = async (userId) => {
|
||||
try {
|
||||
await api.get(`/users/logout/${userId}`);
|
||||
//toast.success(("Desloged!"));
|
||||
//handleDeleteRows(scheduleId)
|
||||
} catch (err) {
|
||||
// toastError(err);
|
||||
}
|
||||
fetchQueries();
|
||||
}, 500);
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
|
||||
};
|
||||
socket.on("ticketStatus", (data) => {
|
||||
// console.log('data: ',data)
|
||||
|
||||
if (data.action === "update") {
|
||||
setStatus(data.ticketStatus.status);
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
socket.on("onlineStatus", (data) => {
|
||||
if (data.action === "logout" || data.action === "update") {
|
||||
// console.log('>>>>>>> data.userOnlineTime: ', data.userOnlineTime)
|
||||
|
||||
//setLoading(true);
|
||||
dispatch({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime });
|
||||
} else if (data.action === "delete") {
|
||||
dispatch({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime });
|
||||
}
|
||||
});
|
||||
|
||||
const delayDebounceFn = setTimeout(() => {
|
||||
socket.on("user", (data) => {
|
||||
if (data.action === "delete") {
|
||||
// console.log(' entrou no delete user: ', data)
|
||||
dispatch({ type: "DELETE_USER", payload: +data.userId });
|
||||
}
|
||||
});
|
||||
|
||||
// setLoading(true);
|
||||
const fetchQueries = async () => {
|
||||
try {
|
||||
return () => {
|
||||
socket.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
let date = new Date().toLocaleDateString('pt-BR').split('/')
|
||||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`
|
||||
useEffect(() => {
|
||||
const delayDebounceFn = setTimeout(() => {
|
||||
const fetchQueries = async () => {
|
||||
try {
|
||||
let date = new Date().toLocaleDateString("pt-BR").split("/");
|
||||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`;
|
||||
|
||||
const dataQuery = await api.get("/reports/user/services", { params: { userId: null, startDate: dateToday, endDate: dateToday }, });
|
||||
dispatch({ type: "RESET" })
|
||||
dispatch({ type: "LOAD_QUERY", payload: dataQuery.data });
|
||||
|
||||
console.log('xxx REPORT 2 dataQuery : ', dataQuery.data)
|
||||
|
||||
//console.log()
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
fetchQueries();
|
||||
|
||||
}, 500);
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
|
||||
socket.on("ticketStatus", (data) => {
|
||||
|
||||
// console.log('data: ',data)
|
||||
|
||||
if(data.action === "update"){
|
||||
setStatus(data.ticketStatus.status)
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("onlineStatus", (data) => {
|
||||
|
||||
if (data.action === "logout" || (data.action === "update")) {
|
||||
|
||||
// console.log('>>>>>>> data.userOnlineTime: ', data.userOnlineTime)
|
||||
|
||||
|
||||
dispatch({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime });
|
||||
|
||||
}
|
||||
else if (data.action === "delete") {
|
||||
dispatch({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
}, []);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const delayDebounceFn = setTimeout(() => {
|
||||
|
||||
const fetchQueries = async () => {
|
||||
|
||||
try {
|
||||
|
||||
let date = new Date().toLocaleDateString('pt-BR').split('/')
|
||||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`
|
||||
|
||||
const _open = await api.get("/tickets/count", { params: { status: 'open', date: dateToday } });
|
||||
const _closed = await api.get("/tickets/count", { params: { status: 'closed', date: dateToday } });
|
||||
const _pending = await api.get("/tickets/count", { params: { status: 'pending', date: dateToday } });
|
||||
|
||||
setOpen(_open.data.count)
|
||||
setClosed(_closed.data.count)
|
||||
setPending(_pending.data.count)
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
fetchQueries();
|
||||
|
||||
}, 500);
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
|
||||
}, [ticketStatusChange]);
|
||||
const _open = await api.get("/tickets/count", {
|
||||
params: { status: "open", date: dateToday },
|
||||
});
|
||||
const _closed = await api.get("/tickets/count", {
|
||||
params: { status: "closed", date: dateToday },
|
||||
});
|
||||
const _pending = await api.get("/tickets/count", {
|
||||
params: { status: "pending", date: dateToday },
|
||||
});
|
||||
|
||||
setOpen(_open.data.count);
|
||||
setClosed(_closed.data.count);
|
||||
setPending(_pending.data.count);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
fetchQueries();
|
||||
}, 500);
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
}, [ticketStatusChange]);
|
||||
|
||||
return (
|
||||
<Can
|
||||
|
@ -404,7 +363,7 @@ const Dashboard = () => {
|
|||
</Typography>
|
||||
<Grid item>
|
||||
<Typography component="h1" variant="h4">
|
||||
{GetTickets("open", "true", "false", "true")}
|
||||
{open}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Paper>
|
||||
|
@ -420,7 +379,7 @@ const Dashboard = () => {
|
|||
</Typography>
|
||||
<Grid item>
|
||||
<Typography component="h1" variant="h4">
|
||||
{GetTickets("pending", "true", "false", "true")}
|
||||
{pending}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Paper>
|
||||
|
@ -436,7 +395,7 @@ const Dashboard = () => {
|
|||
</Typography>
|
||||
<Grid item>
|
||||
<Typography component="h1" variant="h4">
|
||||
{GetTickets("closed", "true", "false", "true")}
|
||||
{closed}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Paper>
|
||||
|
@ -549,6 +508,6 @@ const Dashboard = () => {
|
|||
|
||||
/**/
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default Dashboard
|
||||
export default Dashboard;
|
||||
|
|
|
@ -20,13 +20,9 @@ import Queues from "../pages/Queues/";
|
|||
import { AuthProvider } from "../context/Auth/AuthContext";
|
||||
import { WhatsAppsProvider } from "../context/WhatsApp/WhatsAppsContext";
|
||||
import Route from "./Route";
|
||||
|
||||
|
||||
|
||||
//console.log('---AuthProvider: ',AuthProvider)
|
||||
|
||||
|
||||
|
||||
|
||||
const Routes = () => {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
|
@ -37,41 +33,18 @@ const Routes = () => {
|
|||
<WhatsAppsProvider>
|
||||
<LoggedInLayout>
|
||||
<Route exact path="/" component={Dashboard} isPrivate />
|
||||
<Route
|
||||
exact
|
||||
path="/tickets/:ticketId?"
|
||||
component={Tickets}
|
||||
isPrivate
|
||||
/>
|
||||
|
||||
<Route
|
||||
exact
|
||||
path="/connections"
|
||||
component={Connections}
|
||||
isPrivate
|
||||
/>
|
||||
<Route exact path="/tickets/:ticketId?" component={Tickets} isPrivate />
|
||||
|
||||
<Route exact path="/connections" component={Connections} isPrivate />
|
||||
|
||||
<Route
|
||||
exact
|
||||
path="/report"
|
||||
component={Report}
|
||||
isPrivate
|
||||
/>
|
||||
|
||||
<Route exact path="/report" component={Report} isPrivate />
|
||||
|
||||
<Route exact path="/contacts" component={Contacts} isPrivate />
|
||||
|
||||
<Route exact path="/schedulesReminder" component={SchedulesReminder} isPrivate />
|
||||
|
||||
|
||||
<Route exact path="/users" component={Users} isPrivate />
|
||||
<Route
|
||||
exact
|
||||
path="/quickAnswers"
|
||||
component={QuickAnswers}
|
||||
isPrivate
|
||||
/>
|
||||
<Route exact path="/quickAnswers" component={QuickAnswers} isPrivate />
|
||||
<Route exact path="/Settings" component={Settings} isPrivate />
|
||||
<Route exact path="/Queues" component={Queues} isPrivate />
|
||||
</LoggedInLayout>
|
||||
|
|
Loading…
Reference in New Issue