From cb821793cfc05c40a5c9600dfe154e90fcb7044f Mon Sep 17 00:00:00 2001 From: Marcos Fargas Date: Sat, 17 Oct 2026 22:39:22 +0200 Subject: [PATCH] feat(shell): agrupar secciones CRM, Ads, Social y Organico dentro de Metricas --- src/components/DashboardShell.tsx | 213 +++++++++++++++++++++++------- 1 file changed, 162 insertions(+), 51 deletions(-) diff --git a/src/components/DashboardShell.tsx b/src/components/DashboardShell.tsx index 75a9558..7c0da5e 100644 --- a/src/components/DashboardShell.tsx +++ b/src/components/DashboardShell.tsx @@ -61,34 +61,6 @@ const NAV_ITEMS: NavItem[] = [ iconClass: 'text-brand-500', moduleId: 'kpis', }, - { - href: '/dashboard/crm', - label: 'CRM', - icon: Contact, - iconClass: 'text-teal-500', - moduleId: 'crm', - }, - { - href: '/dashboard/ad-tracker', - label: 'Ads', - icon: Megaphone, - iconClass: 'text-violet-500', - moduleId: 'ad-tracker', - }, - { - href: '/dashboard/social', - label: 'Social', - icon: Share2, - iconClass: 'text-fuchsia-500', - moduleId: 'social', - }, - { - href: '/dashboard/organico', - label: 'Orgánico', - icon: Leaf, - iconClass: 'text-lime-600', - moduleId: 'organico', - }, { href: '/dashboard/marca', label: 'Zona de marca', @@ -266,17 +238,31 @@ export default function DashboardShell({ pathname === '/dashboard/agencia' || (pathname !== null && pathname.startsWith('/dashboard/agencia/')); + const isMetricasRoute = + pathname === '/dashboard/kpis' || + (pathname !== null && pathname.startsWith('/dashboard/kpis/')) || + pathname === '/dashboard/crm' || + (pathname !== null && pathname.startsWith('/dashboard/crm/')) || + pathname === '/dashboard/ad-tracker' || + (pathname !== null && pathname.startsWith('/dashboard/ad-tracker/')) || + isSocialRoute || + pathname === '/dashboard/organico' || + (pathname !== null && pathname.startsWith('/dashboard/organico/')); + const [expandedSections, setExpandedSections] = useState>({}); + const isMetricasOpen = expandedSections['metricas'] ?? isMetricasRoute; const isSocialOpen = expandedSections['social'] ?? isSocialRoute; const isAgenciaOpen = expandedSections['agencia'] ?? isAgenciaRoute; - const toggleSection = (key: 'social' | 'agencia') => { + const toggleSection = (key: 'metricas' | 'social' | 'agencia') => { setExpandedSections((prev) => { const current = - key === 'social' - ? (prev['social'] ?? isSocialRoute) - : (prev['agencia'] ?? isAgenciaRoute); + key === 'metricas' + ? (prev['metricas'] ?? isMetricasRoute) + : key === 'social' + ? (prev['social'] ?? isSocialRoute) + : (prev['agencia'] ?? isAgenciaRoute); return { ...prev, [key]: !current, @@ -290,7 +276,20 @@ export default function DashboardShell({ return enabledModules[id] !== false; }; - const visibleNav = NAV_ITEMS.filter((item) => moduleOn(item.moduleId)); + const isItemVisible = (item: NavItem) => { + if (item.moduleId === 'kpis') { + return ( + moduleOn('kpis') || + moduleOn('crm') || + moduleOn('ad-tracker') || + moduleOn('social') || + moduleOn('organico') + ); + } + return moduleOn(item.moduleId); + }; + + const visibleNav = NAV_ITEMS.filter(isItemVisible); const subLinkCls = (href: string) => `ml-7 flex items-center gap-2.5 rounded-md px-3 py-1.5 text-[13px] font-medium transition-colors ${ @@ -322,40 +321,152 @@ export default function DashboardShell({