import { Link } from "@tanstack/react-router";
import { Bell, Logs, Server, Settings } from "lucide-react";

import {
	SidebarGroup,
	SidebarGroupContent,
	SidebarGroupLabel,
	SidebarMenu,
	SidebarMenuButton,
	SidebarMenuItem,
	useSidebar,
} from "../ui/sidebar";

// type AdminSidebarProps = {
// 	session: {
// 		user: {
// 			name?: string | null;
// 			email?: string | null;
// 			role?: string | string[];
// 		};
// 	} | null;
//};

export default function AdminSidebar({ session }: any) {
	const { setOpen } = useSidebar();
	const items = [
		{
			title: "Notifications",
			url: "/admin/notifications",
			icon: Bell,
			role: ["systemAdmin", "admin"],
			module: "admin",
			active: true,
		},
		{
			title: "Settings",
			url: "/admin/settings",
			icon: Settings,
			role: ["systemAdmin"],
			module: "admin",
			active: true,
		},
		{
			title: "Servers",
			url: "/admin/servers",
			icon: Server,
			role: ["systemAdmin", "admin"],
			module: "admin",
			active: true,
		},
		{
			title: "Logs",
			url: "/admin/logs",
			icon: Logs,
			role: ["systemAdmin", "admin"],
			module: "admin",
			active: true,
		},
		// {
		// 	title: "Modules",
		// 	url: "/admin/modules",
		// 	icon: Settings,
		// 	role: ["systemAdmin", "admin"],
		// 	module: "admin",
		// 	active: true,
		// },
		// {
		// 	title: "Servers",
		// 	url: "/admin/servers",
		// 	icon: Server,
		// 	role: ["systemAdmin", "admin"],
		// 	module: "admin",
		// 	active: true,
		// },
	];
	return (
		<SidebarGroup>
			<SidebarGroupLabel>Admin</SidebarGroupLabel>
			<SidebarGroupContent>
				<SidebarMenu>
					{items.map((item) => (
						<>
							{item.role.includes(session.user.role) && (
								<SidebarMenuItem key={item.title}>
									<SidebarMenuButton asChild>
										<Link to={item.url} onClick={() => setOpen(false)}>
											<item.icon />
											<span>{item.title}</span>
										</Link>
									</SidebarMenuButton>
								</SidebarMenuItem>
							)}
						</>
					))}
				</SidebarMenu>
			</SidebarGroupContent>
		</SidebarGroup>
	);
}
