Ajuste em Massa - Paciente, Terapeuta, Clinica e Admin - Inicio agenda

This commit is contained in:
Leonardo
2026-02-22 17:56:01 -03:00
parent 6eff67bf22
commit 89b4ecaba1
77 changed files with 9433 additions and 1995 deletions
+18 -3
View File
@@ -25,8 +25,21 @@ const { layoutState } = useLayout()
const tenantStore = useTenantStore()
const entitlementsStore = useEntitlementsStore()
/**
* ✅ Role canônico pro MENU:
* - Prioriza o role do tenant (mesma fonte usada pelo router guard)
* - Faz fallback pro sessionRole (ex.: telas fora de tenant)
*/
const navRole = computed(() => {
return tenantStore.activeRole || sessionRole.value || null
})
const model = computed(() => {
const base = getMenuByRole(sessionRole.value, { isSaasAdmin: sessionIsSaasAdmin.value }) || []
// ✅ fonte correta: tenant role (clinic_admin/therapist/patient)
// fallback: profiles.role (admin/therapist/patient)
const effectiveRole = tenantStore.activeRole || sessionRole.value
const base = getMenuByRole(effectiveRole, { isSaasAdmin: sessionIsSaasAdmin.value }) || []
const normalize = (s) => String(s || '').toLowerCase()
const priorityOrder = (group) => {
@@ -41,6 +54,7 @@ const model = computed(() => {
const tenantId = computed(() => tenantStore.activeTenantId || null)
// quando troca tenant -> recarrega entitlements
watch(
tenantId,
async (id) => {
@@ -50,8 +64,9 @@ watch(
{ immediate: true }
)
// ✅ quando troca role efetivo do menu (tenant role / session role) -> recarrega entitlements do tenant atual
watch(
() => sessionRole.value,
() => navRole.value,
async () => {
if (!tenantId.value) return
entitlementsStore.invalidate()
@@ -480,4 +495,4 @@ function onSearchFocus () {
@created="onQuickCreated"
/>
</div>
</template>
</template>
+5 -5
View File
@@ -44,13 +44,13 @@ function close () {
} catch {}
}
function goMyProfile () {
function goMyProfile() {
close()
// navegação segura por name
// Navegação segura para Account → Profile
safePush(
{ name: 'MeuPerfil' },
'/me/perfil'
{ name: 'account-profile' },
'/account/profile'
)
}
@@ -66,7 +66,7 @@ function goSettings () {
}
if (r === 'patient') {
router.push('/patient/conta')
router.push('/patient/portal')
return
}
+1 -1
View File
@@ -157,7 +157,7 @@ async function irCadastroCompleto () {
layoutState.menuHoverActive = false
await nextTick()
router.push('/admin/pacientes/cadastro')
router.push('/admin/patients/cadastro')
}
</script>
+8 -1
View File
@@ -200,7 +200,14 @@ async function logout() {
try {
await supabase.auth.signOut()
} finally {
router.push('/auth/login')
// limpa possíveis intenções guardadas
sessionStorage.removeItem('redirect_after_login')
sessionStorage.removeItem('intended_area')
// ✅ vai para HomeCards
router.replace('/')
// Use router.replace('/') e não push,
// assim o usuário não consegue voltar com o botão "voltar" para uma rota protegida.
}
}
File diff suppressed because it is too large Load Diff