import { Link } from "@tanstack/react-router";
import {
	Building2,
	Forklift,
	Hourglass,
	ReceiptText,
	Wrench,
} from "lucide-react";
import { userAccess } from "@/lib/authClient";
import {
	SidebarGroup,
	SidebarGroupContent,
	SidebarGroupLabel,
	SidebarMenu,
	SidebarMenuButton,
	SidebarMenuItem,
} from "../ui/sidebar";
import type { Items } from "./SideBarNav";

export default function ForkliftSideBar() {
	const items: Items[] = [
		{
			title: "Lease Companies",
			url: "/lst/app/forklifts/companies",
			icon: Building2,
			role: ["systemAdmin", "admin"],
			module: "forklifts",
			active: true,
		},
		{
			title: "Leases",
			url: "/lst/app/forklifts/leases",
			icon: ReceiptText,
			role: ["systemAdmin", "admin"],
			module: "forklifts",
			active: true,
		},
		{
			title: "Invoices",
			url: "/lst/app/forklifts/invoices",
			icon: ReceiptText,
			role: ["systemAdmin", "admin", "manager"],
			module: "forklifts",
			active: true,
		},
		{
			title: "Repairs",
			url: "/lst/app/admin/settings",
			icon: Wrench,
			role: ["systemAdmin", "admin", "manager"],
			module: "forklifts",
			active: true,
		},
		{
			title: "Hours",
			url: "/lst/app/admin/settings",
			icon: Hourglass,
			role: ["systemAdmin", "admin", "manager", "supervisor"],
			module: "forklifts",
			active: true,
		},
		{
			title: "Forklifts",
			url: "/lst/app/admin/modules",
			icon: Forklift,
			role: ["systemAdmin", "admin", "manager", "supervisor"],
			module: "forklifts",
			active: true,
		},
	];
	return (
		<SidebarGroup>
			<SidebarGroupLabel>Forklifts</SidebarGroupLabel>
			<SidebarGroupContent>
				<SidebarMenu>
					{items.map((item) => (
						<SidebarMenuItem key={item.title}>
							<>
								{userAccess(item.module, item.role) && item.active && (
									<SidebarMenuButton asChild>
										<Link to={item.url}>
											<item.icon />
											<span>{item.title}</span>
										</Link>
									</SidebarMenuButton>
								)}
							</>
						</SidebarMenuItem>
					))}
				</SidebarMenu>
			</SidebarGroupContent>
		</SidebarGroup>
	);
}
