import { useSidebarStore } from "@/store/SidebarStore"; import { cn } from "@/util/utils"; import { NavLink, useMatches } from "react-router-dom"; import { Badge } from "./ui/badge"; type Props = { title: string; links: Array<{ label: string; to: string; newTab?: boolean; disabled?: boolean; beta?: boolean; icon?: React.ReactNode; }>; }; function NavLinkGroup({ title, links }: Props) { const { collapsed } = useSidebarStore(); const matches = useMatches(); const groupIsActive = matches.some((match) => { const inputs = links.map((link) => link.to); return inputs.includes(match.pathname); }); return (
{title}
{links.map((link) => { return ( { return cn( "block rounded-lg py-2 pl-3 text-slate-400 hover:bg-muted hover:text-primary", { "bg-muted": isActive, }, { "text-primary": groupIsActive, "px-3": collapsed, }, ); }} >
{link.icon} {!collapsed && link.label}
{!collapsed && link.disabled && ( {link.beta ? "Beta" : "Training"} )}
); })}
); } export { NavLinkGroup };