88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { usePathname } from "next/navigation";
|
|
import { ChevronLeft, Shield, Languages, LogOut } from "lucide-react";
|
|
import { cn } from "@/lib/utils";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Separator } from "@/components/ui/separator";
|
|
import { Button } from "@/components/ui/button";
|
|
import { useAdminLogin } from "./login/useAdminLogin";
|
|
import { adminNavItems } from "./constants";
|
|
|
|
export function AdminSidebar() {
|
|
const pathname = usePathname();
|
|
const { logout } = useAdminLogin();
|
|
|
|
return (
|
|
<aside className="hidden w-56 shrink-0 border-r border-border bg-card lg:flex lg:flex-col">
|
|
<div className="flex h-12 items-center gap-2 px-4">
|
|
<div className="flex size-6 items-center justify-center rounded-md bg-foreground">
|
|
<Languages className="size-3 text-background" />
|
|
</div>
|
|
<span className="text-xs font-semibold tracking-tight text-foreground">
|
|
Office Translator
|
|
</span>
|
|
<Badge
|
|
variant="outline"
|
|
className="ml-auto px-1.5 py-0 text-[10px] font-medium text-muted-foreground"
|
|
>
|
|
Admin
|
|
</Badge>
|
|
</div>
|
|
|
|
<Separator />
|
|
|
|
<nav className="flex flex-1 flex-col gap-0.5 px-2 py-3">
|
|
{adminNavItems.map((item) => {
|
|
const isActive = pathname === item.href;
|
|
return (
|
|
<Link
|
|
key={item.label}
|
|
href={item.href}
|
|
className={cn(
|
|
"flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors",
|
|
isActive
|
|
? "bg-secondary text-foreground"
|
|
: "text-muted-foreground hover:bg-secondary/60 hover:text-foreground"
|
|
)}
|
|
>
|
|
<item.icon className="size-3.5 shrink-0" />
|
|
{item.label}
|
|
</Link>
|
|
);
|
|
})}
|
|
</nav>
|
|
|
|
<Separator />
|
|
|
|
<div className="flex flex-col gap-1 px-2 py-2">
|
|
<div className="flex items-center gap-2 px-2.5 py-1">
|
|
<Shield className="size-3 text-muted-foreground" />
|
|
<span className="text-[10px] text-muted-foreground">Superadmin access</span>
|
|
</div>
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
className="h-7 justify-start gap-2 text-xs text-muted-foreground"
|
|
asChild
|
|
>
|
|
<Link href="/dashboard">
|
|
<ChevronLeft className="size-3" />
|
|
User Dashboard
|
|
</Link>
|
|
</Button>
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
className="h-7 justify-start gap-2 text-xs text-muted-foreground hover:text-destructive"
|
|
onClick={logout}
|
|
>
|
|
<LogOut className="size-3" />
|
|
Logout
|
|
</Button>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|