fix(newwhats): resolve conversa por 9º dígito e nome do paciente no slot da agenda
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -459,14 +459,15 @@ export const AgendaView: React.FC<{ onNavigate?: (view: string) => void }> = ({
|
|||||||
const inativo = st === 'cancelado' || st === 'remarcar';
|
const inativo = st === 'cancelado' || st === 'remarcar';
|
||||||
// Prioridade: status (falta/cancelado) > cor própria do agendamento (ex.: importada do Google) > cor do dentista.
|
// 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 cor = faltou ? '#ef4444' : inativo ? '#cbd5e1' : ((ag as any).cor || (dentist ? dentist.corAgenda : '#94a3b8'));
|
||||||
|
const nomePac = (ag as any).pacienteNome || (ag as any).pacientenome || '';
|
||||||
return {
|
return {
|
||||||
id: ag.id,
|
id: ag.id,
|
||||||
title: `${ag.pacienteNome} - ${ag.procedimento}`,
|
title: `${nomePac} - ${ag.procedimento}`,
|
||||||
start: ag.start,
|
start: ag.start,
|
||||||
end: ag.end,
|
end: ag.end,
|
||||||
backgroundColor: cor,
|
backgroundColor: cor,
|
||||||
borderColor: cor,
|
borderColor: cor,
|
||||||
extendedProps: { ...ag, isGoogle: false, dentistaNome: dentist?.nome }
|
extendedProps: { ...ag, pacienteNome: nomePac, isGoogle: false, dentistaNome: dentist?.nome }
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -161,8 +161,11 @@ const DrawerInner: React.FC<Omit<WhatsChatDrawerProps, 'isOpen'>> = ({ onClose,
|
|||||||
store.setActiveChat(null);
|
store.setActiveChat(null);
|
||||||
try {
|
try {
|
||||||
const send = normalizeSendPhone(phoneDigits);
|
const send = normalizeSendPhone(phoneDigits);
|
||||||
// O GET /inbox?search=<dígitos> casa por `jid contains` no backend.
|
// Busca pelos ÚLTIMOS 8 dígitos (estáveis): o WhatsApp grava o jid do BR sem o
|
||||||
await store.loadChats(activeInstanceId, { search: send });
|
// 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 chats = useChatStore.getState().chats;
|
||||||
const hit = chats.find((c) =>
|
const hit = chats.find((c) =>
|
||||||
samePhone(c.contactPhone || c.jid.split('@')[0], send)) ?? null;
|
samePhone(c.contactPhone || c.jid.split('@')[0], send)) ?? null;
|
||||||
|
|||||||
Reference in New Issue
Block a user