import { 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, BarChart3, User, Globe, Award, Key, Inbox, CheckCircle, XCircle, Clock, Eye, Mail, Briefcase } from "lucide-react"; export default function AdminApplications() { const { user, logout } = useAuth(); const [, setLocation] = useLocation(); const [selectedApp, setSelectedApp] = useState(null); const queryClient = useQueryClient(); const { data: applications, isLoading } = useQuery({ queryKey: ["applications"], queryFn: async () => { const res = await fetch("/api/applications"); if (!res.ok) throw new Error("Failed to fetch applications"); return res.json(); }, }); const updateApplicationMutation = useMutation({ mutationFn: async ({ id, status }: { id: string; status: string }) => { const res = await fetch(`/api/applications/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ status }), }); if (!res.ok) throw new Error("Failed to update application"); return res.json(); }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["applications"] }); setSelectedApp(null); }, }); const handleLogout = async () => { await logout(); setLocation("/"); }; const getStatusColor = (status: string) => { switch (status?.toLowerCase()) { case 'approved': case 'accepted': return 'bg-green-500/10 text-green-500'; case 'rejected': case 'declined': return 'bg-destructive/10 text-destructive'; case 'pending': case 'review': return 'bg-yellow-500/10 text-yellow-500'; default: return 'bg-white/5 text-muted-foreground'; } }; const getStatusIcon = (status: string) => { switch (status?.toLowerCase()) { case 'approved': case 'accepted': return ; case 'rejected': case 'declined': return ; default: return ; } }; const pendingCount = applications?.filter((a: any) => a.status === 'pending' || !a.status).length || 0; return (

Applications

{applications?.length || 0} total applications • {pendingCount} pending review

{isLoading ? ( ) : applications?.length === 0 ? ( ) : ( applications?.map((app: any) => ( )) )}
Applicant Position Status Submitted Actions
Loading...
No applications found
{app.name || app.applicant_name || 'Unknown'}
{app.email || app.applicant_email || 'No email'}
{app.position || app.role || 'General'} {getStatusIcon(app.status)} {app.status || 'pending'} {app.submitted_at ? new Date(app.submitted_at).toLocaleDateString() : 'N/A'}
{(!app.status || app.status === 'pending') && ( <> )}
{selectedApp && (

Application Details

Submitted {selectedApp.submitted_at ? new Date(selectedApp.submitted_at).toLocaleString() : 'Unknown'}

{selectedApp.name || selectedApp.applicant_name || 'Unknown'}
{selectedApp.email || selectedApp.applicant_email || 'No email'}
{selectedApp.position || selectedApp.role || 'General'}
{getStatusIcon(selectedApp.status)} {selectedApp.status || 'pending'}
{(selectedApp.message || selectedApp.cover_letter || selectedApp.description) && (
{selectedApp.message || selectedApp.cover_letter || selectedApp.description}
)} {selectedApp.resume_url && ( )}
{(!selectedApp.status || selectedApp.status === 'pending') && ( <> )}
)}
); } 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}
); }