fix: listener para ticket deletado

websocket
adriano 2024-05-22 12:51:11 -03:00
parent fce5554681
commit 435a577bed
1 changed files with 6 additions and 2 deletions

View File

@ -143,11 +143,15 @@ const Ticket = () => {
socket.on("connect", onConnectTicket) socket.on("connect", onConnectTicket)
const onTicketTicket = (data) => { const onTicketTicket = (data) => {
if (data.action === "update" && data.ticket.id == ticketId) { const isSameTicket = +data?.ticket?.id === +ticketId || +data.ticketId === +ticketId
if (!isSameTicket) return
if (data.action === "update") {
setTicket(data.ticket) setTicket(data.ticket)
} }
if (data.action === "delete") { if (data.action === "deleteForever") {
console.log('delete forever')
toast.success("Ticket deleted sucessfully.") toast.success("Ticket deleted sucessfully.")
history.push("/tickets") history.push("/tickets")
} }