Fix deeplink /crm/conversas não existe; alias dinâmico por role
Bug: toast do SLA tinha deeplink /crm/conversas que caía em NotFound. As rotas reais são /therapist/conversas (terapeuta) e /admin/conversas (clinic_admin), contextuais por role. Fix: novo sistema de aliases em AppLayout.resolveDeeplink. DEEPLINK_ALIASES traduz links semânticos (ex: /conversas, /crm/conversas) pra rota real baseado em tenantStore.activeRole. Edge do SLA agora emite /conversas (alias) em vez de path hardcoded; frontend resolve. Padrão aplicável pras próximas features — basta registrar novo alias aqui quando a rota depender de contexto. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,12 +21,29 @@ import { useRoute, useRouter } from 'vue-router';
|
|||||||
|
|
||||||
const router = useRouter();
|
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) {
|
function goToDeeplink(link) {
|
||||||
if (!link) return;
|
if (!link) return;
|
||||||
if (typeof link === 'string' && link.startsWith('/')) {
|
const resolved = resolveDeeplink(link);
|
||||||
router.push(link);
|
if (typeof resolved === 'string' && resolved.startsWith('/')) {
|
||||||
|
router.push(resolved);
|
||||||
} else {
|
} else {
|
||||||
window.location.href = link;
|
window.location.href = resolved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ async function notifyBreach(supa: SupabaseClient, params: {
|
|||||||
title,
|
title,
|
||||||
detail,
|
detail,
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
deeplink: '/crm/conversas',
|
deeplink: '/conversas',
|
||||||
actionLabel: 'Abrir CRM',
|
actionLabel: 'Abrir CRM',
|
||||||
thread_key: params.thread_key
|
thread_key: params.thread_key
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user