From d0f7914c5807b259f8fe56c868b0a7f2183935e9 Mon Sep 17 00:00:00 2001 From: VPS 4 Builder Date: Thu, 14 May 2026 22:53:19 +0200 Subject: [PATCH] fix(agenda): atender paciente busca via API antes de navegar para GTO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Substitui o match de nome no frontend por uma busca real no backend. handleAtender agora chama getPacientes(pacienteNome), seta o paciente diretamente no store e navega — LancarGTO abre com o card já preenchido. Co-Authored-By: Claude Sonnet 4.6 --- frontend/views/AgendaView.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/views/AgendaView.tsx b/frontend/views/AgendaView.tsx index 74590ce..3a1e7fa 100644 --- a/frontend/views/AgendaView.tsx +++ b/frontend/views/AgendaView.tsx @@ -376,9 +376,19 @@ export const AgendaView: React.FC<{ onNavigate?: (view: string) => void }> = ({ const currentUserEmail = HybridBackend.getCurrentUser(); const gtoStore = useGTOStore(); - const handleAtender = () => { + const handleAtender = async () => { if (!selectedAppointment || !onNavigate) return; - gtoStore.setPendingSearch(selectedAppointment.pacienteNome); + try { + const result = await HybridBackend.getPacientes(selectedAppointment.pacienteNome); + const list = Array.isArray(result) ? result : (result?.data ?? []); + if (list.length > 0) { + gtoStore.setPaciente(list[0]); + } else { + gtoStore.setPendingSearch(selectedAppointment.pacienteNome); + } + } catch { + gtoStore.setPendingSearch(selectedAppointment.pacienteNome); + } setShowDetails(false); onNavigate('lancar-gto'); };