diff --git a/frontend/src/components/TicketsList/index.js b/frontend/src/components/TicketsList/index.js index da436d2..0aa075a 100644 --- a/frontend/src/components/TicketsList/index.js +++ b/frontend/src/components/TicketsList/index.js @@ -125,6 +125,15 @@ const reducer = (state, action) => { return [...state]; } + if (action.type === "UPDATE_TICKET_CONTACT") { + const contact = action.payload; + const ticketIndex = state.findIndex(t => t.contactId === contact.id); + if (ticketIndex !== -1) { + state[ticketIndex].contact = contact; + } + return [...state]; + } + if (action.type === "DELETE_TICKET") { const ticketId = action.payload; const ticketIndex = state.findIndex(t => t.id === ticketId); @@ -201,6 +210,15 @@ const TicketsList = ({ status, searchParam, showAll }) => { } }); + socket.on("contact", data => { + if (data.action === "update") { + dispatch({ + type: "UPDATE_TICKET_CONTACT", + payload: data.contact, + }); + } + }); + return () => { socket.disconnect(); };