import {Printer} from "lucide-react";
import {
    SidebarGroup,
    SidebarGroupContent,
    SidebarGroupLabel,
    SidebarMenu,
    SidebarMenuButton,
    SidebarMenuItem,
} from "../../ui/sidebar";
import {hasPageAccess} from "@/utils/userAccess";
import {User} from "@/types/users";

const items = [
    {
        title: "One Click Print",
        url: "/ocp",
        icon: Printer,
        role: ["viewer"],
        module: "ocp",
        active: true,
    },
];

export function ProductionSideBar({user, moduleID}: {user: User | null; moduleID: string}) {
    return (
        <SidebarGroup>
            <SidebarGroupLabel>Production</SidebarGroupLabel>
            <SidebarGroupContent>
                <SidebarMenu>
                    {items.map((item) => (
                        <SidebarMenuItem key={item.title}>
                            <>
                                {hasPageAccess(user, item.role, moduleID) && item.active && (
                                    <SidebarMenuButton asChild>
                                        <a href={item.url}>
                                            <item.icon />
                                            <span>{item.title}</span>
                                        </a>
                                    </SidebarMenuButton>
                                )}
                            </>
                        </SidebarMenuItem>
                    ))}
                </SidebarMenu>
            </SidebarGroupContent>
        </SidebarGroup>
    );
}
