FIX: Removidas validações includes('@') incompatíveis com IDs limpos
Some checks are pending
Deploy Dev / deploy (push) Waiting to run
Some checks are pending
Deploy Dev / deploy (push) Waiting to run
O guard 'activeContactId.includes('@')' bloqueava silenciosamente o
carregamento de mensagens, assume/release/close de chat e envio de
mensagens, pois o backend agora usa números limpos (sem @c.us) como
identificadores. Trocado por verificação simples de truthy.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cd112326d6
commit
873a586d0c
@ -295,7 +295,7 @@ export function useChat() {
|
||||
activeAssignment?.status === 'queued' &&
|
||||
(isAdminUser || !activeAssignment.area_nome || currentUserAreas.includes(activeAssignment.area_nome)),
|
||||
);
|
||||
const canAssumeChat = Boolean(!isPaused && activeContact?.id?.includes('@') && currentUserId && isQueuedForUserArea);
|
||||
const canAssumeChat = Boolean(!isPaused && activeContact?.id && currentUserId && isQueuedForUserArea);
|
||||
const canReply = Boolean(!isPaused && isAssignedToCurrentUser && !isWaitingCustomerReply);
|
||||
const assignmentLabel = activeAssignment?.user_id
|
||||
? isWaitingCustomerReply
|
||||
@ -460,7 +460,7 @@ export function useChat() {
|
||||
let isMounted = true;
|
||||
|
||||
async function loadMessages() {
|
||||
if (!activeContactId.includes('@')) return;
|
||||
if (!activeContactId) return;
|
||||
setIsLoadingMessages(true);
|
||||
try {
|
||||
const data = await listWhatsappMessages(activeContactId);
|
||||
@ -628,7 +628,7 @@ export function useChat() {
|
||||
}
|
||||
|
||||
async function assumeChat(contactId = activeContactId) {
|
||||
if (!contactId?.includes('@') || !currentUserId) return null;
|
||||
if (!contactId || !currentUserId) return null;
|
||||
const targetContact = contacts.find((contact) => contact.id === contactId) || activeContact;
|
||||
const targetAssignment = targetContact?.assignment || null;
|
||||
const areaId = targetContact?.areaId || targetAssignment?.area_id || areaOptions.find((area) => currentUserAreas.includes(area.nome))?.id;
|
||||
@ -653,7 +653,7 @@ export function useChat() {
|
||||
}
|
||||
|
||||
async function releaseChat() {
|
||||
if (!activeContactId?.includes('@')) return;
|
||||
if (!activeContactId) return;
|
||||
|
||||
try {
|
||||
const assignment = await releaseWhatsappChat(activeContactId);
|
||||
@ -670,7 +670,7 @@ export function useChat() {
|
||||
}
|
||||
|
||||
async function closeChat() {
|
||||
if (!activeContactId?.includes('@')) return;
|
||||
if (!activeContactId) return;
|
||||
|
||||
const confirmed = window.confirm('Tem certeza que deseja encerrar este atendimento?');
|
||||
if (!confirmed) return;
|
||||
@ -786,7 +786,7 @@ export function useChat() {
|
||||
}
|
||||
setAttachedFile(null);
|
||||
|
||||
if (!contactId.includes('@')) return;
|
||||
if (!contactId) return;
|
||||
|
||||
try {
|
||||
await sendWhatsappMessage({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user