From 5964b48b36a1392f5923a888af3305f171b37c98 Mon Sep 17 00:00:00 2001 From: gustavo-gsp Date: Fri, 6 Sep 2024 19:36:43 -0300 Subject: [PATCH] fix: correct and add functionalities in the IVR for two different numbers Details: - Fixed issues in the IVR system. - Added new functionalities to support two different phone numbers. --- .../WbotServices/wbotMessageListener.ts | 15 +++++++++- .../ContactCreateTicketModal/index.js | 2 +- .../components/TransferTicketModal/index.js | 29 +++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index 272e673..e09af21 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -613,6 +613,15 @@ const transferTicket = async ( } else if (typeof queueName == "number") { queue = queues[queueName]; } + const whatsapp: any = await whatsappInfo(ticket?.whatsappId); + + const outService = await outOfService(whatsapp?.number); + if (outService.length > 0) { + const { type, msg: msgOutService } = outService[0]; + console.log(`${type} message ignored on queue`); + botSendMessage(ticket, `\u200e${msgOutService}`); + return; + } if (queue) { await assingContactByQueue(ticket, queue.id); @@ -1235,7 +1244,11 @@ const menu = async (userTyped: string, whatsappId: any, contactId: any, ticket: let option = data.find((o: any) => o.id == currentMenu[3]); response = data.find((o: any) => o.id == option.idnext); - if (response) response.value = `Seja bem-vindo(a) ao WhatsApp Gertec.\nQual o seu nome?`; + if (response){ + const whatsapp = await whatsappCache(ticket.whatsappId); + if (whatsapp.number === '551121736500') response.value = `Seja bem-vindo(a) ao WhatsApp Gertec.\nQual o seu nome?`; + else response.value = `Seja bem-vindo(a) ao WhatsApp GĂ©Run.\nQual o seu nome?`; + } }else response = data.find((o: any) => o.idmaster == menuOption.id); if (response) { diff --git a/frontend/src/components/ContactCreateTicketModal/index.js b/frontend/src/components/ContactCreateTicketModal/index.js index b8310e7..40e0362 100644 --- a/frontend/src/components/ContactCreateTicketModal/index.js +++ b/frontend/src/components/ContactCreateTicketModal/index.js @@ -199,7 +199,7 @@ const ContactCreateTicketModal = ({ modalOpen, onClose, contactId }) => { style={{ background: id !== itemHover ? "white" : color, }} - >{name[0].toUpperCase() + name.slice(1).toLowerCase()} + >{name} ))} diff --git a/frontend/src/components/TransferTicketModal/index.js b/frontend/src/components/TransferTicketModal/index.js index 02acdfc..4b54640 100644 --- a/frontend/src/components/TransferTicketModal/index.js +++ b/frontend/src/components/TransferTicketModal/index.js @@ -71,7 +71,12 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => { if (!whatsApps) return [] const whatsAppsQueues = whatsApps.map(({ queues }) => queues) //const whatsAppsQueues = whatsApps.filter(({ status }) => status === "CONNECTED" ).map(({ queues }) => queues) - const uniqueQueuesAvailable = queueArraysToOneArray(whatsAppsQueues) + const uniqueQueuesAvailable = queueArraysToOneArray(whatsAppsQueues); + uniqueQueuesAvailable.sort((a, b) => { + if (a.name.toLowerCase() < b.name.toLowerCase()) return -1; + if (a.name.toLowerCase() > b.name.toLowerCase()) return 1; + return 0; + }); return uniqueQueuesAvailable }, [whatsApps]) @@ -91,6 +96,11 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => { const { id, color, name } = q return { id, color, name } }) + userQueues.sort((a, b) => { + if (a.name.toLowerCase() < b.name.toLowerCase()) return -1; + if (a.name.toLowerCase() > b.name.toLowerCase()) return 1; + return 0; + }); setQueues(userQueues) setSelectedQueue('') @@ -194,7 +204,16 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => { const { data } = await api.get(`/users/all`, { params: { userId: user.id }, }) - + data.queues.sort((a, b) => { + if (a.name.toLowerCase() < b.name.toLowerCase()) return -1; + if (a.name.toLowerCase() > b.name.toLowerCase()) return 1; + return 0; + }); + data.users.sort((a, b) => { + if (a.name.toLowerCase() < b.name.toLowerCase()) return -1; + if (a.name.toLowerCase() > b.name.toLowerCase()) return 1; + return 0; + }); setUsers(data.users) setQueuesByWhats(data.queues) setQueues(data.queues) @@ -205,6 +224,12 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => { params: { profile: 'user', transferToOtherQueues: user.transferToOtherQueues }, }) + data.users.sort((a, b) => { + if (a.name.toLowerCase() < b.name.toLowerCase()) return -1; + if (a.name.toLowerCase() > b.name.toLowerCase()) return 1; + return 0; + }); + setUsers(data.users) setQueues(_queues2) }