fix(agenda): atender paciente busca via API antes de navegar para GTO
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user