'use client'; import React, { useState, useEffect } from 'react'; import Link from 'next/link'; import { usePathname, useRouter } from 'next/navigation'; import { Building, FileText, Settings, LogOut, Menu, X } from 'lucide-react'; interface AdminLayoutProps { children: React.ReactNode; } export default function AdminLayout({ children }: AdminLayoutProps) { const [isAuthenticated, setIsAuthenticated] = useState(false); const [isLoading, setIsLoading] = useState(true); const [isSidebarOpen, setIsSidebarOpen] = useState(false); const pathname = usePathname(); const router = useRouter(); useEffect(() => { // Проверяем авторизацию const adminAuth = localStorage.getItem('adminAuth'); if (adminAuth) { setIsAuthenticated(true); } setIsLoading(false); }, []); const handleLogin = (username: string, password: string) => { // Простая проверка (в реальном проекте должна быть серверная авторизация) if (username === 'admin' && password === 'admin123') { localStorage.setItem('adminAuth', JSON.stringify({ username, role: 'admin' })); setIsAuthenticated(true); return true; } return false; }; const handleLogout = () => { localStorage.removeItem('adminAuth'); setIsAuthenticated(false); router.push('/admin'); }; const navigation = [ { name: 'Новости', href: '/admin/news', icon: FileText }, { name: 'Настройки', href: '/admin/settings', icon: Settings }, ]; if (isLoading) { return (
Войдите в систему управления