import { motion } from "framer-motion";
import { Link, useLocation } from "wouter";
import { useQuery } from "@tanstack/react-query";
import { useAuth } from "@/lib/auth";
import {
Users, FileCode, Shield, Activity, LogOut,
Home, BarChart3, Settings, ChevronRight, User, Globe, Award, Key, Inbox
} from "lucide-react";
import gridBg from '@assets/generated_images/dark_subtle_digital_grid_texture.png';
export default function Admin() {
const { user, logout } = useAuth();
const [, setLocation] = useLocation();
const { data: metrics } = useQuery({
queryKey: ["metrics"],
queryFn: async () => {
const res = await fetch("/api/metrics");
return res.json();
},
});
const { data: profiles } = useQuery({
queryKey: ["profiles"],
queryFn: async () => {
const res = await fetch("/api/profiles");
return res.json();
},
});
const { data: projects } = useQuery({
queryKey: ["projects"],
queryFn: async () => {
const res = await fetch("/api/projects");
return res.json();
},
});
const handleLogout = async () => {
await logout();
setLocation("/");
};
return (
{/* Sidebar */}
{user?.username}
{user?.isAdmin ? "Administrator" : "Member"}
{/* Main Content */}
Welcome back, {user?.username?.split('@')[0] || 'Admin'}!
{new Date().getHours() < 12 ? 'Good morning' : new Date().getHours() < 17 ? 'Good afternoon' : 'Good evening'}. Here's your ecosystem overview.
Dashboard
Real-time ecosystem metrics from Supabase
{/* Metrics Grid */}
}
/>
}
/>
}
/>
}
/>
{/* Recent Activity */}
{/* Recent Profiles */}
Recent Architects
{profiles?.slice(0, 5).map((profile: any) => (
{profile.username}
Level {profile.level} • {profile.role}
{profile.status}
))}
{/* Recent Projects */}
Active Projects
{projects?.slice(0, 5).map((project: any) => (
{project.title}
{project.engine}
))}
{/* XP Stats */}
Ecosystem Stats
{metrics?.totalXP?.toLocaleString() || 0}
Total XP Earned
{metrics?.avgLevel || 1}
Avg Level
{profiles?.filter((p: any) => p.onboarded).length || 0}
Onboarded
{profiles?.filter((p: any) => p.role === 'admin').length || 0}
Admins
);
}
function NavItem({ icon, label, href, active = false }: {
icon: React.ReactNode;
label: string;
href: string;
active?: boolean;
}) {
return (
{icon}
{label}
);
}
function MetricCard({ title, value, icon }: { title: string; value: number; icon: React.ReactNode }) {
return (
{value}
);
}