({ items }: MainProps)
| 21 | } |
| 22 | |
| 23 | export function Main({ items }: MainProps) { |
| 24 | const { isMobile, setOpenMobile } = useSidebar() |
| 25 | const router = useRouterState() |
| 26 | const currentPath = router.location.pathname |
| 27 | |
| 28 | const handleMenuClick = () => { |
| 29 | if (isMobile) { |
| 30 | setOpenMobile(false) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | return ( |
| 35 | <SidebarGroup> |
| 36 | <SidebarGroupContent> |
| 37 | <SidebarMenu> |
| 38 | {items.map((item) => { |
| 39 | const isActive = currentPath === item.path |
| 40 | |
| 41 | return ( |
| 42 | <SidebarMenuItem key={item.title}> |
| 43 | <SidebarMenuButton |
| 44 | tooltip={item.title} |
| 45 | isActive={isActive} |
| 46 | asChild |
| 47 | > |
| 48 | <RouterLink to={item.path} onClick={handleMenuClick}> |
| 49 | <item.icon /> |
| 50 | <span>{item.title}</span> |
| 51 | </RouterLink> |
| 52 | </SidebarMenuButton> |
| 53 | </SidebarMenuItem> |
| 54 | ) |
| 55 | })} |
| 56 | </SidebarMenu> |
| 57 | </SidebarGroupContent> |
| 58 | </SidebarGroup> |
| 59 | ) |
| 60 | } |
nothing calls this directly
no test coverage detected