From c2a1f8f70196c6da72495e205a903d0793fda8e1 Mon Sep 17 00:00:00 2001 From: VPS 4 Builder Date: Fri, 3 Jul 2026 00:29:02 +0200 Subject: [PATCH] =?UTF-8?q?fix(newwhats):=20resolve=20conversa=20por=209?= =?UTF-8?q?=C2=BA=20d=C3=ADgito=20e=20nome=20do=20paciente=20no=20slot=20d?= =?UTF-8?q?a=20agenda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - WhatsChatDrawer: busca o chat pelos últimos 8 dígitos (o WhatsApp grava o jid BR sem o 9º dígito, ex. 556799591687), evitando falso "sem conversa" - AgendaView: slot usa pacienteNome || pacientenome (backend retorna minúsculo), corrigindo o card que não exibia o nome do paciente Co-Authored-By: Claude Opus 4.8 --- frontend/views/AgendaView.tsx | 5 +++-- frontend/views/newwhats/WhatsChatDrawer.tsx | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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;