import React from 'react' import { Link, router } from '@inertiajs/react' import { Sidebar } from 'flowbite-react' import { HiLogout } from 'react-icons/hi' import { filterOpenMenu } from './helpers' import routes from './routes' const Item = ({ item, children }) => { const Icon = () => item.icon({ className: 'w-6 h-6 text-gray-500 transition duration-75 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white', }) const isActive = route().current(item.active) const className = `flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700 ${ isActive && 'bg-gray-200 dark:bg-gray-700' }` return ( {children} ) } const SubItem = ({ item, children }) => { const Icon = () => item.icon({ className: 'w-6 h-6 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white', }) const isActive = route().current(item.active) const className = `flex items-center w-full p-2 text-gray-900 transition duration-75 rounded-lg pl-11 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700 ${ isActive && 'bg-gray-200 dark:bg-gray-700' }` return ( {children} ) } export default function SidebarNav({ user }) { const menus = routes.filter((item) => { item.open = false if (!item.show) { return null } if (user.role === null) { return filterOpenMenu(user, item) } if (user.role.permissions.find((p) => p.name === item.permission)) { return item } return filterOpenMenu(user, item) }) return ( {menus.map((item) => ( {item.items === undefined ? ( {item.name} ) : ( {item.items.map((item) => ( {item.name} ))} )} ))} router.post(route('logout'))} icon={HiLogout} > Logout Elsoft © {new Date().getFullYear()} ) }
Elsoft © {new Date().getFullYear()}