significant refactor

This commit is contained in:
2025-08-30 01:42:23 -05:00
parent 7136f646a3
commit 052f53444e
106 changed files with 1994 additions and 1701 deletions

View File

@@ -8,11 +8,12 @@ interface NavLinkProps {
href: string;
label: string;
Icon: Icon;
include?: string[];
}
export const NavLink = ({ href, label, Icon }: NavLinkProps) => {
export const NavLink = ({ href, label, Icon, include }: NavLinkProps) => {
const router = useRouterState();
const isActive = useMemo(() => router.location.pathname === href || (router.location.pathname.includes(href) && href !== '/'), [router.location.pathname, href]);
const isActive = useMemo(() => (router.location.pathname === href || (router.location.pathname.includes(href) && href !== '/')) || include?.includes(router.location.pathname), [router.location.pathname, href]);
return (
<Box component={Link} to={href}

View File

@@ -8,6 +8,7 @@ import { useLinks } from "../hooks/use-links";
const Navbar = () => {
const { user, roles } = useAuth()
const isMobile = useIsMobile();
const links = useLinks(user?.id, roles);
if (isMobile) return (

View File

@@ -3,7 +3,6 @@ import { useMemo } from "react";
export const useLinks = (userId: string | undefined, roles: string[]) =>
useMemo(() => {
if (!userId) throw new Error("userId is undefined")
const links = [
{
label: 'Home',
@@ -23,7 +22,8 @@ export const useLinks = (userId: string | undefined, roles: string[]) =>
{
label: 'Profile',
href: `/profile/${userId}`,
Icon: UserCircleIcon
Icon: UserCircleIcon,
include: ['/settings']
}
]