Alteração parcial do dasbord

pull/18/head
adriano 2022-08-08 15:28:47 -03:00
parent 71d69990e2
commit 7cafadc9c1
4 changed files with 31 additions and 8 deletions

View File

@ -74,7 +74,8 @@ const TicketEmiterSumOpenClosedByUser = async (userId: string, startDate: string
}
});
});
};

View File

@ -54,6 +54,12 @@ const CreateTicketService = async ({
TicketEmiterSumOpenClosedByUser(userId.toString(), dateToday.fullDate, dateToday.fullDate)
const io = getIO();
io.emit("ticketStatus", {
action: "update",
ticketStatus: {ticketId: ticket.id, status: ticket.status}
});
//

View File

@ -10,7 +10,7 @@ interface TicketData {
status?: string;
userId?: number;
queueId?: number;
statusChatEnd?: string
statusChatEnd?: string
}
interface Request {
@ -58,8 +58,7 @@ const UpdateTicketService = async ({
action: "delete",
ticketId: ticket.id
});
}
}
io.to(ticket.status)
@ -69,6 +68,13 @@ const UpdateTicketService = async ({
action: "update",
ticket
});
io.emit("ticketStatus", {
action: "update",
ticketStatus: {ticketId: ticket.id, status: ticket.status}
});
return { ticket, oldStatus, oldUserId };
};

View File

@ -207,6 +207,9 @@ const Dashboard = () => {
const [pending, setPending] = useState(0)
const { user } = useContext(AuthContext);
const [ticketStatusChange, setStatus] = useState()
// var userQueueIds = [];
// if (user.queues && user.queues.length > 0) {
@ -286,9 +289,14 @@ const Dashboard = () => {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
// socket.on("ticket", (data) => {
// console.log('OK')
// });
socket.on("ticketStatus", (data) => {
console.log('data: ',data)
if(data.action === "update"){
setStatus(data.ticketStatus.status)
}
});
socket.on("onlineStatus", (data) => {
@ -341,6 +349,8 @@ const Dashboard = () => {
setClosed(_closed.data.count)
setPending(_pending.data.count)
console.log('ALTEROU O STATUS')
} catch (err) {
console.log(err);
@ -352,7 +362,7 @@ const Dashboard = () => {
}, 500);
return () => clearTimeout(delayDebounceFn);
}, [usersOnlineInfo]);
}, [ticketStatusChange]);