Correção da atualização do pending

pull/20/head
adriano 2022-08-09 15:44:28 -03:00
parent 3e418f7c92
commit 5c34b7911e
3 changed files with 35 additions and 40 deletions

View File

@ -50,7 +50,7 @@ const CreateTicketService = async ({
const dateToday = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR }))) const dateToday = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR })))
//openByUser : [ { id: 13, status: 'online' } ] //openByUser : [ { id: 13, status: 'online' } ]
TicketEmiterSumOpenClosedByUser(userId.toString(), dateToday.fullDate, dateToday.fullDate) TicketEmiterSumOpenClosedByUser(userId.toString(), dateToday.fullDate, dateToday.fullDate)

View File

@ -51,14 +51,14 @@ const UpdateTicketService = async ({
await ticket.reload(); await ticket.reload();
const io = getIO(); let io = getIO();
if (ticket.status !== oldStatus || ticket.user?.id !== oldUserId) { if (ticket.status !== oldStatus || ticket.user?.id !== oldUserId) {
io.to(oldStatus).emit("ticket", { io.to(oldStatus).emit("ticket", {
action: "delete", action: "delete",
ticketId: ticket.id ticketId: ticket.id
}); });
} }
io.to(ticket.status) io.to(ticket.status)
@ -68,12 +68,12 @@ const UpdateTicketService = async ({
action: "update", action: "update",
ticket ticket
}); });
io.emit("ticketStatus", {
io.emit("ticketStatus", {
action: "update", action: "update",
ticketStatus: {ticketId: ticket.id, status: ticket.status} ticketStatus: { ticketId: ticket.id, status: ticket.status }
}); });
return { ticket, oldStatus, oldUserId }; return { ticket, oldStatus, oldUserId };

View File

@ -160,30 +160,19 @@ const reducer = (state, action) => {
} }
} }
if(onlineUser.openClosedInQueue){
state[index].openClosedInQueue = onlineUser.openClosedInQueue
if (onlineUser.openClosedInQueue) {
state[index].openClosedInQueue = onlineUser.openClosedInQueue
} }
if(onlineUser.openClosedOutQueue){ if (onlineUser.openClosedOutQueue) {
state[index].openClosedOutQueue = onlineUser.openClosedOutQueue state[index].openClosedOutQueue = onlineUser.openClosedOutQueue
} }
// if(onlineUser.closedTicketByUserIn){
// state[index].closedTicketByUserIn = onlineUser.closedTicketByUserIn
// }
// if(onlineUser.closedTicketByUserOut){
// state[index].closedTicketByUserOut = onlineUser.closedTicketByUserOut
// }
// if(onlineUser.openTicketByUserIn){
// state[index].openTicketByUserIn = onlineUser.openTicketByUserIn
// }
// if(onlineUser.openTicketByUserOut){
// state[index].openTicketByUserOut = onlineUser.openTicketByUserOut
// }
} }
return [...state] return [...state]
@ -291,19 +280,23 @@ const Dashboard = () => {
socket.on("ticketStatus", (data) => { socket.on("ticketStatus", (data) => {
// console.log('data: ',data) console.log('data: ', data)
if(data.action === "update"){ if (data.action === "update") {
setStatus('')
console.log('data.ticketStatus.status: ', data.ticketStatus.status)
setStatus(data.ticketStatus.status) setStatus(data.ticketStatus.status)
} }
}); });
socket.on("onlineStatus", (data) => { socket.on("onlineStatus", (data) => {
if (data.action === "logout" || (data.action === "update")) { if (data.action === "logout" || (data.action === "update")) {
// console.log('>>>>>>> data.userOnlineTime: ', data.userOnlineTime) // console.log('>>>>>>> data.userOnlineTime: ', data.userOnlineTime)
dispatch({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime }); dispatch({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime });
@ -320,7 +313,7 @@ const Dashboard = () => {
// console.log(' entrou no delete user: ', data) // console.log(' entrou no delete user: ', data)
dispatch({ type: "DELETE_USER", payload: +data.userId }); dispatch({ type: "DELETE_USER", payload: +data.userId });
} }
}); });
return () => { return () => {
socket.disconnect(); socket.disconnect();
@ -332,8 +325,9 @@ const Dashboard = () => {
useEffect(() => { useEffect(() => {
const delayDebounceFn = setTimeout(() => { if (ticketStatusChange === '') return
const delayDebounceFn = setTimeout(() => {
const fetchQueries = async () => { const fetchQueries = async () => {
try { try {
@ -358,7 +352,8 @@ const Dashboard = () => {
fetchQueries(); fetchQueries();
}, 500); }, 500);
return () => clearTimeout(delayDebounceFn); return () => clearTimeout(delayDebounceFn);
}, [ticketStatusChange]); }, [ticketStatusChange]);
@ -510,7 +505,7 @@ const Dashboard = () => {
userInfo.openClosedInQueue.map((info, index) => ( userInfo.openClosedInQueue.map((info, index) => (
<> <>
<Typography component="h1" key={index}> <Typography component="h1" key={index}>
{info.name}: OPEN {info.countOpen} | CLOSED {info.countClosed} {info.name}: OPEN {info.countOpen} | CLOSED {info.countClosed}
</Typography> </Typography>
</> </>
)) ))
@ -524,14 +519,14 @@ const Dashboard = () => {
<div>Em atendimento(open/closed) sem fila, conversas iniciadas por atendentes:</div> <div>Em atendimento(open/closed) sem fila, conversas iniciadas por atendentes:</div>
{userInfo.openClosedOutQueue && {userInfo.openClosedOutQueue &&
<Typography component="h1" key={index}> <Typography component="h1" key={index}>
SEM FILA: OPEN {userInfo.openClosedOutQueue.countOpen} | CLOSED {userInfo.openClosedOutQueue.countClosed} SEM FILA: OPEN {userInfo.openClosedOutQueue.countOpen} | CLOSED {userInfo.openClosedOutQueue.countClosed}
</Typography> </Typography>
} }
</div> </div>
{userInfo.statusOnline && userInfo.statusOnline.status === "online" && {userInfo.statusOnline && userInfo.statusOnline.status === "online" &&