From 682840f355e55992a92c9c5ed9adc60322a135e0 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Thu, 21 May 2026 21:29:46 -0300 Subject: [PATCH] patient cadastro: fix nav pra view individual + rename pra singular MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: no melissa, salvar paciente -> "Salvar e ver pacientes" caia em /pages/access. Causa: patientsListRoute() so tinha branches /therapist e /admin, jogava na rota errada que o guard rejeita no contexto melissa. Fix: 1. PatientCadastroDialog + ComponentCadastroRapido — funcao renomeada pra patientViewRoute(patientId). Branch /melissa redireciona pra /melissa/paciente?id= (prontuario individual) quando ha id, ou /melissa/pacientes (lista) sem id. 2. Botao "Salvar e ver pacientes" -> "Salvar e ver paciente" (singular). Reflete a navegacao real: vai pro proprio paciente que acabou de salvar, nao pra lista. 3. onCreated pega data?.id || props.patientId pra montar a rota. Comportamento melissa: salvar paciente -> abre /melissa/paciente ?id= (prontuario). Therapist/admin segue indo pra lista (comportamento pre-existente). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/ComponentCadastroRapido.vue | 20 ++++++++++++++---- src/components/ui/PatientCadastroDialog.vue | 23 ++++++++++++++++----- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/components/ComponentCadastroRapido.vue b/src/components/ComponentCadastroRapido.vue index db29c5f..02fa936 100644 --- a/src/components/ComponentCadastroRapido.vue +++ b/src/components/ComponentCadastroRapido.vue @@ -197,8 +197,17 @@ function generateUser() { }); } -function patientsListRoute() { +// Rota de destino do "Salvar e ver paciente". Em melissa, prefere a +// view individual do paciente recém-criado (id vem de data.id no +// emit('created')); fallback pra lista. +function patientViewRoute(patientId) { const p = String(route.path || ''); + if (p.startsWith('/melissa') && patientId) { + return { path: '/melissa/paciente', query: { id: String(patientId) } }; + } + if (p.startsWith('/melissa')) { + return '/melissa/pacientes'; + } return p.startsWith('/therapist') ? '/therapist/patients' : '/admin/pacientes'; } @@ -252,7 +261,10 @@ async function submit(mode = 'only') { emit('created', data); if (props.closeOnCreated) close(); - if (mode === 'view') await router.push(patientsListRoute()); + if (mode === 'view') { + const pid = data?.id || null; + await router.push(patientViewRoute(pid)); + } } catch (err) { const msg = err?.message || err?.details || 'Não foi possível criar o paciente.'; errorMsg.value = msg; @@ -334,10 +346,10 @@ async function submit(mode = 'only') {