fix(erp): enable erp pages and menu items
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { getUser, User, getToken, saveAuth } from '@/lib/auth';
|
||||
@@ -42,6 +42,7 @@ export const SidebarRail: React.FC<SidebarRailProps> = ({
|
||||
menuItems
|
||||
}) => {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
@@ -340,23 +341,33 @@ export const SidebarRail: React.FC<SidebarRailProps> = ({
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-2 flex-1 overflow-y-auto">
|
||||
{activeMenuItem.subItems?.map((sub) => (
|
||||
<Link
|
||||
key={sub.href}
|
||||
href={sub.href}
|
||||
// onClick={() => setOpenSubmenu(null)} // Removido para manter fixo
|
||||
className={`
|
||||
flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-medium transition-colors mb-1
|
||||
${pathname === sub.href
|
||||
? 'bg-brand-50 dark:bg-brand-900/10 text-brand-600 dark:text-brand-400'
|
||||
: 'text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-zinc-800 hover:text-gray-900 dark:hover:text-white'
|
||||
}
|
||||
`}
|
||||
>
|
||||
<span className={`w-1.5 h-1.5 rounded-full ${pathname === sub.href ? 'bg-brand-500' : 'bg-gray-300 dark:bg-zinc-600'}`} />
|
||||
{sub.label}
|
||||
</Link>
|
||||
))}
|
||||
{activeMenuItem.subItems?.map((sub) => {
|
||||
// Lógica aprimorada de ativo para suportar query params (ex: ?tab=finance)
|
||||
const fullCurrentPath = searchParams.toString()
|
||||
? `${pathname}?${searchParams.toString()}`
|
||||
: pathname;
|
||||
|
||||
const isSubActive = sub.href.includes('?')
|
||||
? fullCurrentPath.includes(sub.href)
|
||||
: pathname === sub.href;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={sub.href}
|
||||
href={sub.href}
|
||||
className={`
|
||||
flex items-center gap-2 px-3 py-2.5 rounded-lg text-xs font-medium transition-colors mb-1
|
||||
${isSubActive
|
||||
? 'bg-brand-50 dark:bg-brand-900/10 text-brand-600 dark:text-brand-400'
|
||||
: 'text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-zinc-800 hover:text-gray-900 dark:hover:text-white'
|
||||
}
|
||||
`}
|
||||
>
|
||||
<span className={`w-1.5 h-1.5 rounded-full ${isSubActive ? 'bg-brand-500' : 'bg-gray-300 dark:bg-zinc-600'}`} />
|
||||
{sub.label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user