import { useEffect, useMemo, useState } from "react"; import { Link } from "react-router-dom"; import Layout from "@/components/Layout"; import { useAuth } from "@/contexts/AuthContext"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import LoadingScreen from "@/components/LoadingScreen"; import { useToast } from "@/hooks/use-toast"; import { aethexUserService, type AethexUserProfile, } from "@/lib/aethex-database-adapter"; import { cn } from "@/lib/utils"; import { Search, RefreshCw, UserRound, Users, Sparkles } from "lucide-react"; const PLATFORM_OPTIONS = [ { value: "all", label: "All Platforms" }, { value: "roblox", label: "Roblox" }, { value: "unity", label: "Unity" }, { value: "unreal", label: "Unreal" }, { value: "godot", label: "Godot" }, { value: "cryengine", label: "CryEngine" }, { value: "other", label: "Other" }, ] as const; const inferPlatforms = (profile: any): string[] => { const out = new Set(); const pushIf = (cond: boolean, v: string) => { if (cond) out.add(v); }; const skills = Array.isArray(profile?.skills) ? (profile.skills as string[]).map((s) => String(s).toLowerCase()) : []; const bio = String(profile?.bio || "").toLowerCase(); const tags = Array.isArray(profile?.tags) ? (profile.tags as string[]).map((t) => String(t).toLowerCase()) : []; const text = [skills.join(" "), tags.join(" "), bio].join(" "); pushIf(/roblox|rbx|luau|roact/.test(text), "roblox"); pushIf(/unity|c#|csharp/.test(text), "unity"); pushIf(/unreal|ue5|ue4|blueprint/.test(text), "unreal"); pushIf(/godot|gdscript/.test(text), "godot"); pushIf(/cryengine/.test(text), "cryengine"); return Array.from(out); }; const realmFilters: Array<{ value: string; label: string }> = [ { value: "all", label: "All Realms" }, { value: "game_developer", label: "Development Forge" }, { value: "client", label: "Strategist Nexus" }, { value: "community_member", label: "Innovation Commons" }, { value: "customer", label: "Experience Hub" }, ]; const realmBadgeStyles: Record = { game_developer: "bg-gradient-to-r from-neon-purple to-aethex-500 text-white", client: "bg-gradient-to-r from-neon-blue to-aethex-400 text-white", community_member: "bg-gradient-to-r from-neon-green to-aethex-600 text-white", customer: "bg-gradient-to-r from-amber-400 to-aethex-700 text-white", }; const realmBannerFallbacks: Record = { game_developer: "from-purple-900/70 via-indigo-800/50 to-slate-900", client: "from-blue-900/70 via-sky-800/50 to-slate-900", community_member: "from-emerald-900/70 via-teal-800/50 to-slate-900", customer: "from-amber-900/70 via-orange-800/50 to-slate-900", }; const getAvailabilityLabel = ( profile: AethexUserProfile & { [key: string]: unknown }, ): string => { const explicit = (profile as any)?.availability_status ?? (profile as any)?.availability ?? (profile as any)?.availability_label ?? (profile as any)?.status; if (typeof explicit === "string" && explicit.trim()) { return explicit.trim(); } if ((profile as any)?.is_available === false) { return "Currently booked"; } if ((profile as any)?.is_available === true) { return "Open for new projects"; } const xp = Number(profile.total_xp ?? 0); const level = Number(profile.level ?? 0); if (xp >= 5000 || level >= 50) { return "Waitlist only"; } if (xp >= 1500 || level >= 20) { return "Limited availability"; } return "Open for collaboration"; }; const getAvailabilityStyles = (label: string) => { const normalized = label.toLowerCase(); if (normalized.includes("waitlist") || normalized.includes("booked")) { return { badge: "border-rose-500/40 bg-rose-500/10 text-rose-100", dot: "bg-rose-400", }; } if (normalized.includes("limited") || normalized.includes("select")) { return { badge: "border-amber-400/40 bg-amber-400/10 text-amber-100", dot: "bg-amber-300", }; } return { badge: "border-emerald-400/40 bg-emerald-400/10 text-emerald-100", dot: "bg-emerald-300", }; }; interface DeveloperCardProps { profile: AethexUserProfile & { email?: string | null }; } const DeveloperCard = ({ profile }: DeveloperCardProps) => { const realmStyle = realmBadgeStyles[profile.user_type] || "bg-aethex-500 text-white"; const fallbackBanner = realmBannerFallbacks[profile.user_type] || "from-slate-900 via-slate-800 to-slate-900"; const isGodMode = (profile.level ?? 1) >= 100; const passportHref = profile.username ? `/passport/${profile.username}` : `/passport/${profile.id}`; const name = profile.full_name || profile.username || "AeThex Explorer"; const initials = name .split(" ") .filter(Boolean) .map((segment) => segment[0]?.toUpperCase()) .join("") .slice(0, 2) || "AE"; const totalXp = Math.max(0, Math.floor(Number(profile.total_xp ?? 0))); const levelValue = Math.max(1, Math.floor(Number(profile.level ?? 1))); const loyaltyPoints = Math.max( 0, Math.floor(Number((profile as any)?.loyalty_points ?? totalXp)), ); const availabilityLabel = getAvailabilityLabel(profile as any); const availabilityStyles = getAvailabilityStyles(availabilityLabel); const experienceLabel = profile.experience_level ? profile.experience_level.replace("_", " ") : null; return (
{initials}
{profile.user_type.replace("_", " ")} {experienceLabel && ( {experienceLabel} )} {isGodMode && ( GOD Mode )}
{name} {profile.email && ( {profile.email} )}
{profile.location && ( {profile.location} )} {availabilityLabel}
{((profile as any)?.platforms as string[] | undefined)?.length ? ((profile as any).platforms as string[]).slice(0, 4).map((p) => ( {p} )) : inferPlatforms(profile).slice(0, 4).map((p) => ( {p} ))}
Level {levelValue.toLocaleString()}
{profile.bio && (

{profile.bio}

)}
XP
{totalXp.toLocaleString()}
Loyalty
{loyaltyPoints.toLocaleString()}
Streak
{(profile.current_streak ?? 0).toLocaleString()} days
{(profile as any)?.skills?.slice(0, 4)?.map((skill: string) => ( {skill} ))} {((profile as any)?.skills?.length || 0) > 4 && ( +{((profile as any)?.skills?.length || 0) - 4} )}
); }; const DevelopersDirectory = () => { const [profiles, setProfiles] = useState([]); const [loading, setLoading] = useState(true); const [search, setSearch] = useState(""); const [realmFilter, setRealmFilter] = useState("all"); const [platformFilter, setPlatformFilter] = useState("all"); const { profile: authProfile } = useAuth(); const myPassportHref = authProfile?.username ? `/passport/${authProfile.username}` : "/passport/me"; const filteredProfiles = useMemo(() => { const lowerSearch = search.trim().toLowerCase(); return profiles.filter((profile) => { const matchesRealm = realmFilter === "all" || profile.user_type === realmFilter; const matchesSearch = lowerSearch ? [profile.full_name, profile.username, (profile as any)?.company] .filter(Boolean) .some((value) => String(value).toLowerCase().includes(lowerSearch)) : true; const platforms: string[] = ((profile as any)?.platforms as any[]) || inferPlatforms(profile); const matchesPlatform = platformFilter === "all" || platforms.map((p) => String(p).toLowerCase()).includes(platformFilter); return matchesRealm && matchesSearch && matchesPlatform; }); }, [profiles, search, realmFilter, platformFilter]); const { toast } = useToast(); const refreshProfiles = async () => { try { setLoading(true); const list = await aethexUserService.listProfiles(60); setProfiles(list); } catch (error: any) { console.error("Failed to load profiles", error); const msg = (typeof error === "string" && error) || error?.message || JSON.stringify(error, Object.getOwnPropertyNames(error)) || "Unknown error"; toast({ variant: "destructive", title: "Failed to load profiles", description: msg, }); setProfiles([]); } finally { setLoading(false); } }; useEffect(() => { refreshProfiles(); }, []); if (loading) { return ; } return (
AeThex Developer Network

Discover AeThex developers

Browse verified builders, clients, and community members across every AeThex realm.

setSearch(event.target.value)} placeholder="Search by name, username, or company" className="border-0 bg-transparent text-slate-100 focus-visible:ring-0" />
{filteredProfiles.length === 0 ? (
No developers found

Try adjusting your search or realm filters. New developers join AeThex every day!

) : (
{filteredProfiles.map((profile) => ( ))}
)}
); }; export default DevelopersDirectory;