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') {