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

View File

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