import { useEffect, useState } from "react"; import { motion } from "framer-motion"; import { Link, useLocation } from "wouter"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import { useAuth } from "@/lib/auth"; import { Users, FileCode, Shield, Activity, LogOut, Home, BarChart3, Settings, User, Search, CheckCircle, XCircle, Eye, Edit, ChevronRight } from "lucide-react"; export default function AdminArchitects() { const { user, isAuthenticated, isLoading: authLoading, logout } = useAuth(); const [, setLocation] = useLocation(); const [searchQuery, setSearchQuery] = useState(""); const [selectedProfile, setSelectedProfile] = useState(null); const queryClient = useQueryClient(); useEffect(() => { if (!authLoading && !isAuthenticated) { setLocation("/login"); } }, [authLoading, isAuthenticated, setLocation]); const { data: profiles, isLoading } = useQuery({ queryKey: ["profiles"], queryFn: async () => { const res = await fetch("/api/profiles"); return res.json(); }, enabled: isAuthenticated, }); const updateProfileMutation = useMutation({ mutationFn: async ({ id, updates }: { id: string; updates: any }) => { const res = await fetch(`/api/profiles/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify(updates), }); if (!res.ok) throw new Error("Failed to update"); return res.json(); }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["profiles"] }); setSelectedProfile(null); }, }); if (authLoading || !isAuthenticated) { return (
Loading...
); } const filteredProfiles = profiles?.filter((p: any) => p.username?.toLowerCase().includes(searchQuery.toLowerCase()) || p.email?.toLowerCase().includes(searchQuery.toLowerCase()) ) || []; const handleLogout = async () => { await logout(); setLocation("/"); }; const toggleVerified = (profile: any) => { updateProfileMutation.mutate({ id: profile.id, updates: { is_verified: !profile.is_verified } }); }; return (
{/* Sidebar */}

AeThex

Command Center

{user?.username}
{user?.isAdmin ? "Administrator" : "Member"}
{/* Main Content */}

Architects

{profiles?.length || 0} registered architects

{/* Search */}
setSearchQuery(e.target.value)} className="bg-card border border-white/10 pl-10 pr-4 py-2 text-sm text-white placeholder-muted-foreground focus:border-primary/50 focus:outline-none w-64" data-testid="input-search" />
{/* Table */}
{isLoading ? ( ) : filteredProfiles.length === 0 ? ( ) : ( filteredProfiles.map((profile: any) => ( )) )}
User Role Level XP Status Verified Actions
Loading...
No architects found
{profile.username}
{profile.username}
{profile.email}
{profile.role} {profile.level} {profile.total_xp} {profile.status}
{/* Profile Detail Modal */} {selectedProfile && (
{selectedProfile.username}

{selectedProfile.username}

{selectedProfile.email}

{selectedProfile.role}
{selectedProfile.level}
{selectedProfile.total_xp}
{selectedProfile.status}
{selectedProfile.aethex_passport_id}
{selectedProfile.is_verified ? 'Yes' : 'No'}
{selectedProfile.bio || 'No bio'}
{selectedProfile.skills?.map((skill: string, i: number) => ( {skill} )) || No skills listed}
)}
); } function NavItem({ icon, label, href, active = false }: { icon: React.ReactNode; label: string; href: string; active?: boolean; }) { return (
{icon} {label}
); }