"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { cn } from "@/lib/utils"; import { LayoutDashboard, Receipt, Clock, FileText, UserCheck, BookOpen, PieChart, BarChart3, Settings, LogOut, ChevronRight, Wallet, Shield, Briefcase, Layers } from "lucide-react"; import { Button } from "@/components/ui/button"; import { signOut } from "next-auth/react"; import { motion, AnimatePresence } from "framer-motion"; interface SidebarItem { title: string; href: string; icon: any; badge?: string | number; } interface SidebarGroup { label: string; items: SidebarItem[]; } const workerGroups: SidebarGroup[] = [ { label: "Main", items: [ { title: "Dashboard", href: "/me/dashboard", icon: LayoutDashboard }, ] }, { label: "Activities", items: [ { title: "Reimbursements", href: "/me/reimbursements", icon: Receipt, badge: "3" }, { title: "Overtime", href: "/me/overtime", icon: Clock }, ] }, { label: "Documents", items: [ { title: "Payslips", href: "/me/payslips", icon: FileText }, ] } ]; const adminGroups: SidebarGroup[] = [ { label: "Management", items: [ { title: "Dashboard", href: "/admin/dashboard", icon: LayoutDashboard }, { title: "Approvals", href: "/admin/approvals", icon: UserCheck, badge: "12" }, ] }, { label: "Accounting", items: [ { title: "Company Ledger", href: "/admin/ledger", icon: BookOpen }, { title: "Budgeting", href: "/admin/budgeting", icon: PieChart }, ] }, { label: "Analytics", items: [ { title: "Reports", href: "/admin/reports", icon: BarChart3 }, ] } ]; interface SidebarProps { portal: "worker" | "admin"; user: { name?: string | null; email?: string | null; role?: string; }; } export function Sidebar({ portal, user }: SidebarProps) { const pathname = usePathname(); const isAdmin = portal === 'admin'; const groups = isAdmin ? adminGroups : workerGroups; // Role-based theme configuration const theme = { accent: isAdmin ? "emerald" : "indigo", gradient: isAdmin ? "from-emerald-600 to-teal-600" : "from-indigo-600 to-violet-600", bgActive: isAdmin ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-900/20 dark:text-emerald-400" : "bg-indigo-50 text-indigo-700 dark:bg-indigo-900/20 dark:text-indigo-400", iconActive: isAdmin ? "text-emerald-600 dark:text-emerald-400" : "text-indigo-600 dark:text-indigo-400", glow: isAdmin ? "shadow-emerald-200/50" : "shadow-indigo-200/50" }; return (
{user.name || 'User Name'}
{user.email}
Vers. 2.4.0 • Secured