import React from 'react' import { Link, router, usePage } from '@inertiajs/react' import { Sidebar } from 'flowbite-react' import { HiLogout } from 'react-icons/hi' import { filterOpenMenu } from './helpers' import routes from './routes' export default function SidebarNav({ user }) { const { props: { app_name }, } = usePage() 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 ? ( router.visit(item.route)} icon={item.icon} active={route().current(item.active)} > {item.name} ) : ( {item.items.map((item) => ( router.visit(item.route) } > {item.name} ))} )}
))} router.post(route('logout'))} icon={HiLogout} > Logout

{app_name} © {new Date().getFullYear()}

) }