diff --git a/src/layout/AppLayout.vue b/src/layout/AppLayout.vue index fecf9d3..8f20cb4 100644 --- a/src/layout/AppLayout.vue +++ b/src/layout/AppLayout.vue @@ -21,12 +21,29 @@ import { useRoute, useRouter } from 'vue-router'; const router = useRouter(); +// Aliases "semânticos" → resolvidos pra rota real com base no role atual. +// Evita que deeplinks gravados no backend quebrem se o caminho da rota mudar +// ou se o usuário logado pertencer a outro contexto (therapist vs clinic_admin). +const DEEPLINK_ALIASES = { + '/crm/conversas': { therapist: '/therapist/conversas', clinic_admin: '/admin/conversas' }, + '/conversas': { therapist: '/therapist/conversas', clinic_admin: '/admin/conversas' } +}; + +function resolveDeeplink(link) { + if (!link || typeof link !== 'string') return link; + const alias = DEEPLINK_ALIASES[link]; + if (!alias) return link; + const role = tenantStore?.activeRole || 'therapist'; + return alias[role] || alias.therapist; +} + function goToDeeplink(link) { if (!link) return; - if (typeof link === 'string' && link.startsWith('/')) { - router.push(link); + const resolved = resolveDeeplink(link); + if (typeof resolved === 'string' && resolved.startsWith('/')) { + router.push(resolved); } else { - window.location.href = link; + window.location.href = resolved; } } diff --git a/supabase/functions/conversation-sla-check/index.ts b/supabase/functions/conversation-sla-check/index.ts index 3c96381..803eedd 100644 --- a/supabase/functions/conversation-sla-check/index.ts +++ b/supabase/functions/conversation-sla-check/index.ts @@ -279,7 +279,7 @@ async function notifyBreach(supa: SupabaseClient, params: { title, detail, severity: 'error', - deeplink: '/crm/conversas', + deeplink: '/conversas', actionLabel: 'Abrir CRM', thread_key: params.thread_key }