From 0b45abc1972039b89aaf54efbc4d3c8acea611a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Consultor=C3=ADa=20Alcaraz=20Salazar?= Date: Fri, 11 Sep 2026 09:48:37 +0000 Subject: [PATCH] Gerencia rango operativo (crear citas), permisos por prefijo para rutas de detalle, matriz alineada (inventario para recepcion) --- frontend/src/lib/auth.tsx | 22 +++++++++++++++++----- frontend/src/lib/menu-items.ts | 2 ++ odoo-addons/skeen_whatsapp/roles.py | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/auth.tsx b/frontend/src/lib/auth.tsx index dde65ab..a035c31 100644 --- a/frontend/src/lib/auth.tsx +++ b/frontend/src/lib/auth.tsx @@ -14,7 +14,7 @@ const ROLE_RANK: Record = { cosmetologia: 50, psicologa: 50, farmacia: 50, - gerencia: 10, + gerencia: 50, marketing: 10, lectura: 10, }; @@ -155,13 +155,25 @@ export const AuthProvider: FC<{ children: ReactNode }> = ({ children }) => { const canSee = (href: string): boolean => { if (!user) return false; + // Resolución de permiso: primero href exacto (con query), luego por + // prefijo recortando el último segmento (/pacientes/PAT-123 -> /pacientes). + // '/' no matchea subrutas: solo aterriza por canSee('/'). Rutas que no + // matchean nada = visibles para todos. + const segments = href.split('?')[0].split('/').filter(Boolean); + const candidates = [href, ...segments.map((_, i) => '/' + segments.slice(0, segments.length - i).join('/'))].filter((c) => c !== '/' || href === '/'); // Permisos personalizados: lista no vacía manda sobre la matriz por rol if (user.allowed_menus && user.allowed_menus.length > 0) { - return user.allowed_menus.includes(href); + for (const cand of candidates) { + if (user.allowed_menus.includes(cand)) return true; + } + return false; } - const allowed = (menuRoles || MENU_ROLES)[href]; - if (!allowed) return true; - return allowed.includes(user.role); + const matrix = menuRoles || MENU_ROLES; + for (const cand of candidates) { + const allowed = matrix[cand]; + if (allowed) return allowed.includes(user.role); + } + return true; }; return ( diff --git a/frontend/src/lib/menu-items.ts b/frontend/src/lib/menu-items.ts index 652a4f0..685c1c3 100644 --- a/frontend/src/lib/menu-items.ts +++ b/frontend/src/lib/menu-items.ts @@ -23,6 +23,8 @@ export const MENU_ITEMS: { label: string; href: string }[] = [ { label: 'Recomendaciones', href: '/reportes?tab=recomendaciones' }, { label: 'Exportar', href: '/reportes?tab=exportar' }, { label: 'Cumpleañeros', href: '/cumpleanos' }, + { label: 'Mis ventas', href: '/mis-ventas' }, + { label: 'Chat', href: '/chat' }, { label: 'Configuración', href: '/configuracion' }, { label: 'Mensajes WACRM', href: '/wacrm/messages' }, { label: 'Leads WACRM', href: '/wacrm/leads' }, diff --git a/odoo-addons/skeen_whatsapp/roles.py b/odoo-addons/skeen_whatsapp/roles.py index e8e3005..704da7e 100644 --- a/odoo-addons/skeen_whatsapp/roles.py +++ b/odoo-addons/skeen_whatsapp/roles.py @@ -35,7 +35,7 @@ ROLE_RANKS = { 'cosmetologia': 50, 'psicologa': 50, 'farmacia': 50, - 'gerencia': 10, + 'gerencia': 50, 'marketing': 10, 'lectura': 10, }