import { Link, useLocation } from "wouter"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import { useAuth } from "@/lib/auth"; import { Users, FileCode, Shield, Activity, LogOut, BarChart3, User, AlertTriangle, CheckCircle, XCircle, Globe, Award, Key, Inbox } from "lucide-react"; export default function AdminAegis() { const { user, logout } = useAuth(); const [, setLocation] = useLocation(); const queryClient = useQueryClient(); const { data: alerts } = useQuery({ queryKey: ["alerts"], queryFn: async () => { const res = await fetch("/api/alerts"); if (!res.ok) return []; return res.json(); }, }); const { data: authLogs } = useQuery({ queryKey: ["auth-logs-recent"], queryFn: async () => { const res = await fetch("/api/auth-logs"); if (!res.ok) return []; return res.json(); }, }); const resolveAlertMutation = useMutation({ mutationFn: async ({ id, is_resolved }: { id: string; is_resolved: boolean }) => { const res = await fetch(`/api/alerts/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ is_resolved }), }); if (!res.ok) throw new Error("Failed to update alert"); return res.json(); }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["alerts"] }); }, }); const handleLogout = async () => { await logout(); setLocation("/"); }; const failedLogins = authLogs?.filter((l: any) => l.event_type?.includes('fail')).length || 0; const successLogins = authLogs?.filter((l: any) => l.event_type?.includes('success')).length || 0; const unresolvedAlerts = alerts?.filter((a: any) => !a.is_resolved).length || 0; return (

Aegis Monitor

Real-time security monitoring from your database

Shield Active
Auth Events
{authLogs?.length || 0}
Last 100 events
Failed Logins
{failedLogins}
Blocked attempts
Successful Logins
{successLogins}
Verified access
Active Alerts
{unresolvedAlerts}
Unresolved
{alerts && alerts.length > 0 && (

System Alerts

{alerts.slice(0, 10).map((alert: any) => (
{alert.type}
{alert.message}
{alert.is_resolved ? 'resolved' : 'active'}
))}
)}

Recent Auth Events

{authLogs?.slice(0, 10).map((log: any) => (
{log.event_type?.includes('success') ? ( ) : log.event_type?.includes('fail') ? ( ) : ( )} {log.event_type}
{log.ip_address || 'N/A'} {log.created_at ? new Date(log.created_at).toLocaleString() : ''}
))}
); } function Sidebar({ user, onLogout, active }: { user: any; onLogout: () => void; active: string }) { return (

AeThex

Command Center

{user?.username}
{user?.isAdmin ? "Administrator" : "Member"}
); } function NavItem({ icon, label, href, active = false }: { icon: React.ReactNode; label: string; href: string; active?: boolean }) { return (
{icon} {label}
); }