fix: resolve issues with WhatsApp creation and editing, message input, and ControlByNumber errors
Details: - Fixed issue where the 'number' field was not being saved during WhatsApp creation and editing. - Resolved problem where text in the message input was being cleared upon receiving a new message. - Addressed errors in ControlByNumber when ticketId was not found.merge-socket
parent
b9f8bfc8d5
commit
e30573519d
|
@ -377,9 +377,11 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
|||
} else if (!isOfficial) {
|
||||
phoneNumberId = "";
|
||||
wabaId = "";
|
||||
number = "";
|
||||
//number = "";
|
||||
}
|
||||
if(!number){
|
||||
number = getNumberFromName(name)
|
||||
}
|
||||
|
||||
let invalidPhoneName = validatePhoneName(name);
|
||||
|
||||
if (invalidPhoneName) {
|
||||
|
@ -479,9 +481,11 @@ export const update = async (
|
|||
} else if (!isOfficial) {
|
||||
whatsappData.phoneNumberId = "";
|
||||
whatsappData.wabaId = "";
|
||||
whatsappData.number = "";
|
||||
//whatsappData.number = "";
|
||||
}
|
||||
if(!whatsappData?.number){
|
||||
whatsappData.number = getNumberFromName(whatsappData.name)
|
||||
}
|
||||
|
||||
const { whatsapp, oldDefaultWhatsapp } = await UpdateWhatsAppService({
|
||||
whatsappData,
|
||||
whatsappId
|
||||
|
|
|
@ -13,43 +13,44 @@ async function controllByNumber() {
|
|||
let controll: any[] = [];
|
||||
|
||||
for (const ticket of tickets) {
|
||||
let match = ticket.match(/"whatsappId":(\d+)/);
|
||||
let match = ticket?.match(/"whatsappId":(\d+)/);
|
||||
let whatsappId = match ? match[1] : null;
|
||||
|
||||
const whatsapp = await get({
|
||||
key: `whatsapp:${whatsappId}`
|
||||
});
|
||||
|
||||
match = whatsapp.match(/"number":"(\d+)"/);
|
||||
match = whatsapp?.match(/"number":"(\d+)"/);
|
||||
let number = match ? match[1] : null;
|
||||
|
||||
match = ticket.match(/"id":(\d+)/);
|
||||
match = ticket?.match(/"id":(\d+)/);
|
||||
let ticketId = match ? match[1] : null;
|
||||
|
||||
number = JSON.parse(number);
|
||||
ticketId = JSON.parse(ticketId);
|
||||
|
||||
const index = controll.findIndex((c: any) => c.number == number);
|
||||
const index = controll?.findIndex((c: any) => c.number == number);
|
||||
|
||||
if (index == -1) {
|
||||
controll.push({ ticketId, number });
|
||||
controll?.push({ ticketId, number });
|
||||
}
|
||||
}
|
||||
|
||||
const ticketIds = controll.map((c: any) => c.ticketId);
|
||||
const ticketIds = controll?.map((c: any) => c.ticketId);
|
||||
|
||||
console.log("=======> ticketIds: ", ticketIds);
|
||||
//console.log("=======> ticketIds: ", ticketIds);
|
||||
|
||||
for (const ticketId of ticketIds) {
|
||||
const ticket: any = await Ticket.findByPk(ticketId);
|
||||
if(ticket){
|
||||
const { status } = ticket;
|
||||
|
||||
const { status } = ticket;
|
||||
|
||||
if (status == "pending") {
|
||||
await UpdateTicketService({
|
||||
ticketData: { statusChatEnd: uuidv4() },
|
||||
ticketId: ticket.id
|
||||
});
|
||||
if (status && status == "pending") {
|
||||
await UpdateTicketService({
|
||||
ticketData: { statusChatEnd: uuidv4() },
|
||||
ticketId: ticket.id
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ const MessageInput = ({ ticketStatus, ticketLastMessage, ticketIsRemote }) => {
|
|||
setInputMessage(ticketLastMessage)
|
||||
}
|
||||
else {
|
||||
setInputMessage("")
|
||||
//setInputMessage("")
|
||||
}
|
||||
}, [countTicketMsg, ticketIsRemote, ticketLastMessage])
|
||||
|
||||
|
|
Loading…
Reference in New Issue