diff --git a/frontend/views/AgendaView.tsx b/frontend/views/AgendaView.tsx index c460d80..e54a85f 100644 --- a/frontend/views/AgendaView.tsx +++ b/frontend/views/AgendaView.tsx @@ -459,14 +459,15 @@ export const AgendaView: React.FC<{ onNavigate?: (view: string) => void }> = ({ const inativo = st === 'cancelado' || st === 'remarcar'; // Prioridade: status (falta/cancelado) > cor própria do agendamento (ex.: importada do Google) > cor do dentista. const cor = faltou ? '#ef4444' : inativo ? '#cbd5e1' : ((ag as any).cor || (dentist ? dentist.corAgenda : '#94a3b8')); + const nomePac = (ag as any).pacienteNome || (ag as any).pacientenome || ''; return { id: ag.id, - title: `${ag.pacienteNome} - ${ag.procedimento}`, + title: `${nomePac} - ${ag.procedimento}`, start: ag.start, end: ag.end, backgroundColor: cor, borderColor: cor, - extendedProps: { ...ag, isGoogle: false, dentistaNome: dentist?.nome } + extendedProps: { ...ag, pacienteNome: nomePac, isGoogle: false, dentistaNome: dentist?.nome } }; }); diff --git a/frontend/views/newwhats/WhatsChatDrawer.tsx b/frontend/views/newwhats/WhatsChatDrawer.tsx index 2ad8037..72ad9a5 100644 --- a/frontend/views/newwhats/WhatsChatDrawer.tsx +++ b/frontend/views/newwhats/WhatsChatDrawer.tsx @@ -161,8 +161,11 @@ const DrawerInner: React.FC> = ({ onClose, store.setActiveChat(null); try { const send = normalizeSendPhone(phoneDigits); - // O GET /inbox?search= casa por `jid contains` no backend. - await store.loadChats(activeInstanceId, { search: send }); + // Busca pelos ÚLTIMOS 8 dígitos (estáveis): o WhatsApp grava o jid do BR sem o + // 9º dígito (ex.: 556799591687), então buscar o número completo (13 dígitos) + // não casaria no `jid contains` do backend. O samePhone (últimos 8) filtra. + const tail8 = send.replace(/\D/g, '').slice(-8); + await store.loadChats(activeInstanceId, { search: tail8 }); const chats = useChatStore.getState().chats; const hit = chats.find((c) => samePhone(c.contactPhone || c.jid.split('@')[0], send)) ?? null;