import type { LucideIcon } from "lucide-react"; import { ChevronRight } from "lucide-react"; import type * as React from "react"; import { Badge } from "@/components/ui/badge"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, useSidebar, } from "@/components/ui/sidebar"; import { cn } from "@/lib/utils"; export interface AppSidebarProps { children?: React.ReactNode; logo?: { src: string; alt: string; }; title?: string; navigationLabel?: string; variant?: "sidebar" | "inset"; footer?: React.ReactNode; } export interface NavLink { name: string; icon: LucideIcon; page: string; count?: number; active?: boolean; disabled?: boolean; items?: NavLink[]; onClick?: () => void; } export interface SidebarSectionProps { label?: string; items: NavLink[]; } const AppSidebar = ({ children, logo, title, navigationLabel, items, footer, variant, ...props }: SidebarSectionProps & AppSidebarProps) => { const { state } = useSidebar(); const isCollapsed = state === "collapsed"; return (
{logo && ( {logo.alt} )} {title && (

{title}

)}
{navigationLabel && ( {navigationLabel} )} {items.map((link) => { // Check if this item has sub-items if (link.items && link.items.length > 0) { return ( {link.icon && } {link.name} {link.count !== undefined && link.count > 0 && ( {link.count} )} {link.items.map((subLink) => ( {subLink.icon && ( )} {subLink.name} {subLink.count !== undefined && subLink.count > 0 && ( {subLink.count} )} ))} ); } return ( {link.icon && } {link.name} {link.count !== undefined && link.count > 0 && ( {link.count} )} ); })} {children && (
{children}
)}
{footer && {footer}}
); }; AppSidebar.displayName = "AppSidebar"; export default AppSidebar;