Download src/components/layout/Sidebar.tsx from sarransh/task-manager-system: direct link, hf CLI and curl.
- Browser
- Download file 5.82 kB
-
https://huggingface.co/spaces/sarransh/task-manager-system/resolve/main/src/components/layout/Sidebar.tsx
- Command line
-
hf download hf://spaces/sarransh/task-manager-system/src/components/layout/Sidebar.tsx
-
curl -L -o Sidebar.tsx https://huggingface.co/spaces/sarransh/task-manager-system/resolve/main/src/components/layout/Sidebar.tsx
5.82 kB
| "use client"; | |
| import Link from "next/link"; | |
| import { usePathname } from "next/navigation"; | |
| import { | |
| LayoutDashboard, | |
| ListTodo, | |
| Timer, | |
| CalendarDays, | |
| Users, | |
| Settings, | |
| LogOut, | |
| Coffee, | |
| ClipboardCheck, | |
| Activity | |
| } from "lucide-react"; | |
| import { signOut, useSession } from "next-auth/react"; | |
| const menuItems = [ | |
| { name: "Dashboard", href: "/dashboard", icon: LayoutDashboard }, | |
| { name: "Sprints", href: "/sprints", icon: Timer }, | |
| { name: "Tasks", href: "/tasks", icon: ListTodo }, | |
| { name: "Timesheets", href: "/timesheets", icon: CalendarDays }, | |
| { name: "Daily Scrum", href: "/scrum", icon: Coffee }, | |
| ]; | |
| const adminItems = [ | |
| { name: "User Management", href: "/admin/users", icon: Users }, | |
| { name: "Attendance", href: "/admin/attendance", icon: ClipboardCheck }, | |
| { name: "Activity Log", href: "/admin/activity", icon: Activity }, // Activity Log Access | |
| { name: "Settings", href: "/admin/settings", icon: Settings }, | |
| ]; | |
| export default function Sidebar() { | |
| const pathname = usePathname(); | |
| const { data: session } = useSession(); | |
| // Allow admin access if role is ADMIN | |
| const isAdmin = session?.user?.role === "ADMIN"; | |
| return ( | |
| <aside className="fixed left-0 top-0 h-full w-64 bg-[hsl(var(--card))] border-r border-[hsl(var(--border))] flex flex-col z-50"> | |
| <div className="p-6 flex items-center gap-3 border-b border-[hsl(var(--border))]"> | |
| <div className="w-8 h-8 rounded-lg bg-[hsl(var(--primary))] flex items-center justify-center"> | |
| <span className="text-white font-bold">TM</span> | |
| </div> | |
| <span className="font-bold text-lg tracking-tight">TaskManager</span> | |
| </div> | |
| <nav className="flex-1 overflow-y-auto py-6 px-3 space-y-1"> | |
| <div className="text-xs font-semibold text-[hsl(var(--muted-foreground))] uppercase tracking-wider mb-2 px-3"> | |
| Overview | |
| </div> | |
| {menuItems.map((item) => { | |
| const isActive = pathname.startsWith(item.href); | |
| return ( | |
| <Link | |
| key={item.href} | |
| href={item.href} | |
| className={`flex items-center gap-3 px-3 py-2.5 rounded-md transition-all duration-200 group ${isActive | |
| ? "bg-[hsl(var(--primary)/0.1)] text-[hsl(var(--primary))]" | |
| : "text-[hsl(var(--muted-foreground))] hover:bg-[hsl(var(--muted))]/50 hover:text-[hsl(var(--foreground))]" | |
| }`} | |
| > | |
| <item.icon className="w-5 h-5" /> | |
| <span className="font-medium text-sm">{item.name}</span> | |
| </Link> | |
| ); | |
| })} | |
| {isAdmin && ( | |
| <> | |
| <div className="mt-8 mb-2 px-3 text-xs font-semibold text-[hsl(var(--muted-foreground))] uppercase tracking-wider"> | |
| Administration | |
| </div> | |
| {adminItems.map((item) => { | |
| const isActive = pathname.startsWith(item.href); | |
| return ( | |
| <Link | |
| key={item.href} | |
| href={item.href} | |
| className={`flex items-center gap-3 px-3 py-2.5 rounded-md transition-all duration-200 ${isActive | |
| ? "bg-[hsl(var(--primary)/0.1)] text-[hsl(var(--primary))]" | |
| : "text-[hsl(var(--muted-foreground))] hover:bg-[hsl(var(--muted))]/50 hover:text-[hsl(var(--foreground))]" | |
| }`} | |
| > | |
| <item.icon className="w-5 h-5" /> | |
| <span className="font-medium text-sm">{item.name}</span> | |
| </Link> | |
| ); | |
| })} | |
| </> | |
| )} | |
| </nav> | |
| <div className="p-4 border-t border-[hsl(var(--border))]"> | |
| <Link href="/settings/profile" className="flex items-center gap-3 mb-4 px-2 hover:bg-[hsl(var(--muted)/0.5)] p-2 rounded-md transition-colors cursor-pointer group"> | |
| <div className="w-8 h-8 rounded-full bg-[hsl(var(--muted))] flex items-center justify-center text-xs font-bold group-hover:bg-[hsl(var(--primary)/0.2)] group-hover:text-[hsl(var(--primary))] transition-colors"> | |
| {session?.user?.name?.[0] || "U"} | |
| </div> | |
| <div className="flex-1 min-w-0"> | |
| <p className="text-sm font-medium truncate group-hover:text-[hsl(var(--primary))]">{session?.user?.name || "Guest"}</p> | |
| <p className="text-xs text-[hsl(var(--muted-foreground))] truncate">{session?.user?.email}</p> | |
| </div> | |
| </Link> | |
| <button | |
| onClick={() => signOut()} | |
| className="w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium text-[hsl(var(--destructive-foreground))] bg-[hsl(var(--destructive))] hover:bg-[hsl(var(--destructive)/0.9)] transition-colors" | |
| > | |
| <LogOut className="w-4 h-4" /> | |
| Sign Out | |
| </button> | |
| </div> | |
| </aside> | |
| ); | |
| } | |