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.
gertec
gustavo-gsp 2024-09-06 19:36:43 -03:00
parent bf2dc3de03
commit 5964b48b36
3 changed files with 42 additions and 4 deletions

View File

@ -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) {

View File

@ -199,7 +199,7 @@ const ContactCreateTicketModal = ({ modalOpen, onClose, contactId }) => {
style={{
background: id !== itemHover ? "white" : color,
}}
>{name[0].toUpperCase() + name.slice(1).toLowerCase()}</MenuItem>
>{name}</MenuItem>
))}
</Select>
</FormControl>

View File

@ -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)
}