main: second iter

Signed-off-by: nfel <nfilsaraee@gmail.com>
This commit is contained in:
2025-12-27 22:41:36 +03:30
parent 8a7842e263
commit 9a7e627329
33 changed files with 4865 additions and 81 deletions
+35
View File
@@ -0,0 +1,35 @@
'use client';
import { useEffect } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { useAdmin } from '@/lib/AdminContext';
import AdminSidebar from './AdminSidebar';
export default function AdminLayout({ children }: { children: React.ReactNode }) {
const { isAuthenticated } = useAdmin();
const router = useRouter();
const pathname = usePathname();
useEffect(() => {
if (!isAuthenticated && pathname !== '/admin') {
router.push('/admin');
}
}, [isAuthenticated, router, pathname]);
if (!isAuthenticated && pathname !== '/admin') {
return null;
}
if (pathname === '/admin') {
return <>{children}</>;
}
return (
<div className="min-h-screen bg-gradient-to-br from-primary-900 via-primary-800 to-primary-900 flex">
<AdminSidebar />
<main className="flex-1 overflow-auto">
{children}
</main>
</div>
);
}