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

@ -51,7 +51,7 @@ 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", {
@ -72,7 +72,7 @@ const UpdateTicketService = async ({
io.emit("ticketStatus", { io.emit("ticketStatus", {
action: "update", action: "update",
ticketStatus: {ticketId: ticket.id, status: ticket.status} ticketStatus: { ticketId: ticket.id, status: ticket.status }
}); });

View File

@ -163,27 +163,16 @@ const reducer = (state, action) => {
if(onlineUser.openClosedInQueue){ if (onlineUser.openClosedInQueue) {
state[index].openClosedInQueue = 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,9 +280,13 @@ 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)
} }
}); });
@ -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 {
@ -360,6 +354,7 @@ const Dashboard = () => {
}, 500); }, 500);
return () => clearTimeout(delayDebounceFn); return () => clearTimeout(delayDebounceFn);
}, [ticketStatusChange]); }, [ticketStatusChange]);