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

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>