77 lines
3.1 KiB
JavaScript
77 lines
3.1 KiB
JavaScript
'use client';
|
|
import Link from 'next/link';
|
|
import { usePathname, useRouter } from 'next/navigation';
|
|
import { LayoutDashboard, FileText, Radio, Zap, Settings, LogOut, ExternalLink, MessageCircle, Clock } from 'lucide-react';
|
|
|
|
const NAV = [
|
|
{ href: '/admin', label: 'Дашборд', icon: LayoutDashboard, exact: true },
|
|
{ href: '/admin/articles', label: 'Статьи', icon: FileText },
|
|
{ href: '/admin/drafts', label: 'Черновики', icon: Clock },
|
|
{ href: '/admin/channels', label: 'Каналы', icon: Radio },
|
|
{ href: '/admin/autogen', label: 'Автогенерация', icon: Zap },
|
|
{ href: '/admin/notes', label: 'Заметки', icon: MessageCircle },
|
|
{ href: '/admin/settings', label: 'Настройки', icon: Settings },
|
|
];
|
|
|
|
export default function AdminNav() {
|
|
const pathname = usePathname();
|
|
const router = useRouter();
|
|
|
|
async function logout() {
|
|
await fetch('/admin/api/logout', { method: 'POST' });
|
|
router.push('/admin/login');
|
|
router.refresh();
|
|
}
|
|
|
|
return (
|
|
<header className="border-b border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-900">
|
|
<div className="max-w-6xl mx-auto px-4 h-14 flex items-center gap-6">
|
|
{/* Логотип */}
|
|
<Link href="/admin" className="flex items-center gap-2 font-bold text-sm text-neutral-900 dark:text-neutral-100 shrink-0">
|
|
<span className="w-7 h-7 rounded-lg bg-emerald-500 text-white flex items-center justify-center text-xs font-bold">Z</span>
|
|
Admin
|
|
</Link>
|
|
|
|
{/* Навигация */}
|
|
<nav className="flex items-center gap-1 flex-1">
|
|
{NAV.map(({ href, label, icon: Icon, exact }) => {
|
|
const active = exact ? pathname === href : pathname.startsWith(href);
|
|
return (
|
|
<Link
|
|
key={href}
|
|
href={href}
|
|
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${
|
|
active
|
|
? 'bg-emerald-50 dark:bg-emerald-950 text-emerald-700 dark:text-emerald-400'
|
|
: 'text-neutral-500 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 hover:bg-neutral-100 dark:hover:bg-neutral-800'
|
|
}`}
|
|
>
|
|
<Icon className="w-4 h-4" />
|
|
{label}
|
|
</Link>
|
|
);
|
|
})}
|
|
</nav>
|
|
|
|
{/* Правая часть */}
|
|
<div className="flex items-center gap-2 shrink-0">
|
|
<Link
|
|
href="/"
|
|
target="_blank"
|
|
className="flex items-center gap-1 text-xs text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors"
|
|
>
|
|
<ExternalLink className="w-3.5 h-3.5" />
|
|
Сайт
|
|
</Link>
|
|
<button
|
|
onClick={logout}
|
|
className="flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-sm text-neutral-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-950 transition-colors"
|
|
>
|
|
<LogOut className="w-4 h-4" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|