diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index 1cd1661..2739c73 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -529,6 +529,7 @@ const transferTicket = async ( sendGreetingMessage?: boolean ) => { const botInfo = await BotIsOnQueue("botqueue"); + const io = getIO(); const queuesWhatsGreetingMessage = await queuesOutBot( wbot, @@ -548,6 +549,7 @@ const transferTicket = async ( } if (queue) await botTransferTicket(queue, ticket, sendGreetingMessage); + io.emit('notifyPeding', {data: {ticket, queue}}); }; const botTransferTicket = async ( diff --git a/frontend/src/components/NotificationsPopOver/index.js b/frontend/src/components/NotificationsPopOver/index.js index 89a1155..e93c4cb 100644 --- a/frontend/src/components/NotificationsPopOver/index.js +++ b/frontend/src/components/NotificationsPopOver/index.js @@ -261,32 +261,32 @@ const NotificationsPopOver = () => { }) }else{ user.queues.forEach(queue =>{ - if(queue.id === notify.data.queue?.id){ + if(queue.id === notify.data?.queue?.id){ isQueue = true; } }) - } - if(!isQueue && notify){ - return; - }else{ - const notification = new Notification(`${i18n.t("tickets.notification.messagePeding")} ${notify?.data?.queue?.name}`); - notification.onclick = e => { - e.preventDefault() - window.focus() - historyRef.current.push(`/tickets`) - } - - setDesktopNotifications(prevState => { - const notfiticationIndex = prevState.findIndex( - n => n.tag === notification.tag - ) - if (notfiticationIndex !== -1) { - prevState[notfiticationIndex] = notification - return [...prevState] + if(!isQueue){ + return; + }else { + const notification = new Notification(`${i18n.t("tickets.notification.messagePeding")} ${notify.data?.queue?.name}`); + notification.onclick = e => { + e.preventDefault() + window.focus() + historyRef.current.push(`/tickets`) } - return [notification, ...prevState] - }) - } + + setDesktopNotifications(prevState => { + const notfiticationIndex = prevState.findIndex( + n => n.tag === notification.tag + ) + if (notfiticationIndex !== -1) { + prevState[notfiticationIndex] = notification + return [...prevState] + } + return [notification, ...prevState] + }) + } + } soundAlertRef.current() } diff --git a/frontend/src/pages/Report/index.js b/frontend/src/pages/Report/index.js index d8b0ee1..9229285 100644 --- a/frontend/src/pages/Report/index.js +++ b/frontend/src/pages/Report/index.js @@ -235,19 +235,22 @@ let columnsData = [ { title: `${i18n.t("reports.listColumns.column1_7")}`, field: 'createdAt' }, { title: `${i18n.t("reports.listColumns.column1_8")}`, field: 'updatedAt' }, - { title: `${i18n.t("reports.listColumns.column1_9")}`, field: 'statusChatEnd' }] + { title: `${i18n.t("reports.listColumns.column1_9")}`, field: 'statusChatEnd' }, + { title: `Mensagens`, field: 'messagesToFilter', searchable: true, hidden: true }, +] let columnsDataSuper = [ { title: `${i18n.t("reports.listColumns.column1_1")}`, field: 'whatsapp.name' }, { title: `${i18n.t("reports.listColumns.column1_2")}`, field: 'user.name' }, { title: `${i18n.t("reports.listColumns.column0_3")}`, field: 'contact.name' }, { title: `${i18n.t("reports.listColumns.column1_5")}`, field: 'queue.name' }, - + { title: 'Status', field: 'status' }, - + { title: `${i18n.t("reports.listColumns.column1_7")}`, field: 'createdAt' }, { title: `${i18n.t("reports.listColumns.column1_8")}`, field: 'updatedAt' }, - { title: `${i18n.t("reports.listColumns.column1_9")}`, field: 'statusChatEnd' } + { title: `${i18n.t("reports.listColumns.column1_9")}`, field: 'statusChatEnd' }, + { title: `Mensagens`, field: 'messagesToFilter', searchable: true, hidden: true }, ] @@ -369,8 +372,12 @@ const Report = () => { filterQueuesTickets = ticketsQueue.filter(ticket => ticket?.queue?.name === userQueues[0]?.name) } data.tickets = filterQueuesTickets - dispatchQ({ type: "LOAD_QUERY", payload: data.tickets }) - + const tickets = data.tickets.map(ticket => ({ + ...ticket, + messagesToFilter: ticket.messages.map(message => message.body).join(' '), + })); + dispatchQ({ type: "LOAD_QUERY", payload: tickets }) + console.log(tickets); setHasMore(data.hasMore) setTotalCountTickets(data.count) setLoading(false)