diff --git a/src/app/admin/dashboard/page.tsx b/src/app/admin/dashboard/page.tsx new file mode 100644 index 0000000..e2adbb6 --- /dev/null +++ b/src/app/admin/dashboard/page.tsx @@ -0,0 +1,111 @@ +"use client"; + +import { useEffect, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import { ThemeProvider } from '@/providers/themeProvider/ThemeProvider'; +import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen'; + +export default function AdminDashboardPage() { + const router = useRouter(); + const [isAdmin, setIsAdmin] = useState(false); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const token = localStorage.getItem('adminToken'); + const cookieToken = document.cookie.split('; ').find(row => row.startsWith('adminToken='))?.split('=')[1]; + + if (token === 'mock-admin-token' && cookieToken === 'mock-admin-token') { + setIsAdmin(true); + } else { + router.push('/admin/login?message=Unauthorized'); + } + setLoading(false); + }, [router]); + + const handleLogout = () => { + localStorage.removeItem('adminToken'); + document.cookie = 'adminToken=; path=/; max-age=0;'; + router.push('/admin/login'); + }; + + const navItems = [ + { name: "Home", id: "/" }, + { name: "Services", id: "/services" }, + { name: "Pricing", id: "/pricing" }, + { name: "FAQ", id: "/faq" }, + { name: "Contact", id: "/contact" }, + { name: "Admin Login", id: "/admin/login" } + ]; + + if (loading) { + return ( + + + + + + Loading... + + + ); + } + + if (!isAdmin) { + return null; + } + + return ( + + + + + + + + Welcome to Admin Dashboard! + This is a protected route, accessible only to authenticated administrators. + + Logout + + + + + ); +} \ No newline at end of file
Loading...
This is a protected route, accessible only to authenticated administrators.