35 lines
897 B
TypeScript
35 lines
897 B
TypeScript
"use client";
|
|
|
|
import { useAuth } from "@/components/AuthProvider";
|
|
import { AdminDashboard } from "@/components/AdminDashboard";
|
|
import { useRouter } from "next/navigation";
|
|
import { useEffect } from "react";
|
|
|
|
export default function AdminPage() {
|
|
const { user, loading } = useAuth();
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
if (loading) return;
|
|
if (!user) { router.push("/"); return; }
|
|
if (!user.isAdmin) { router.push("/"); return; }
|
|
}, [user, loading, router]);
|
|
|
|
if (loading) {
|
|
return (
|
|
<div className="flex items-center justify-center min-h-[60vh]">
|
|
<div className="text-center font-mono text-sm text-slate-600 animate-pulse">
|
|
<div className="text-3xl mb-2">🔐</div>
|
|
Verifying command clearance...
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!user || !user.isAdmin) {
|
|
return null;
|
|
}
|
|
|
|
return <AdminDashboard />;
|
|
}
|