71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
'use client';
|
|
|
|
import { useRouter, usePathname } from 'next/navigation';
|
|
import Link from 'next/link';
|
|
import Cookies from 'js-cookie';
|
|
|
|
export default function DashboardLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const router = useRouter();
|
|
const pathname = usePathname();
|
|
|
|
const handleLogout = () => {
|
|
Cookies.remove('isAuthenticated', { path: '/' });
|
|
router.push('/login');
|
|
};
|
|
|
|
const isActive = (path: string) => pathname === path;
|
|
|
|
return (
|
|
<div className="min-h-screen bg-[var(--background)]">
|
|
<nav className="bg-[var(--card-bg)] border-b border-[var(--card-border)]">
|
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div className="flex justify-between h-16">
|
|
<div className="flex">
|
|
<div className="flex-shrink-0 flex items-center">
|
|
<h1 className="text-xl font-bold text-[var(--text-primary)]">Admin Panel</h1>
|
|
</div>
|
|
<div className="ml-6 flex items-center space-x-4">
|
|
<Link
|
|
href="/dashboard"
|
|
className={`px-3 py-2 rounded-md text-sm font-medium ${
|
|
isActive('/dashboard')
|
|
? 'text-[var(--accent)]'
|
|
: 'text-[var(--text-secondary)] hover:text-[var(--text-primary)]'
|
|
}`}
|
|
>
|
|
Dashboard
|
|
</Link>
|
|
<Link
|
|
href="/dashboard/chat"
|
|
className={`px-3 py-2 rounded-md text-sm font-medium ${
|
|
isActive('/dashboard/chat')
|
|
? 'text-[var(--accent)]'
|
|
: 'text-[var(--text-secondary)] hover:text-[var(--text-primary)]'
|
|
}`}
|
|
>
|
|
Chat Moderation
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center">
|
|
<button
|
|
onClick={handleLogout}
|
|
className="ml-4 px-4 py-2 text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors"
|
|
>
|
|
Logout
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main className="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|