import { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; import Layout from "@/components/Layout"; import { Button } from "@/components/ui/button"; import { useAuth } from "@/contexts/AuthContext"; import { useArmTheme } from "@/contexts/ArmThemeContext"; import { supabase } from "@/lib/supabase"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import LoadingScreen from "@/components/LoadingScreen"; import { Code, Users, Briefcase, ExternalLink, ArrowRight, AlertCircle, Edit, Save, } from "lucide-react"; import { TeamWidget } from "@/components/TeamWidget"; const API_BASE = import.meta.env.VITE_API_BASE || ""; export default function DevLinkDashboard() { const navigate = useNavigate(); const { user, loading: authLoading } = useAuth(); const { theme } = useArmTheme(); const [activeTab, setActiveTab] = useState("overview"); const [profile, setProfile] = useState(null); const [opportunities, setOpportunities] = useState([]); const [teams, setTeams] = useState([]); const [loading, setLoading] = useState(true); const [isEditing, setIsEditing] = useState(false); useEffect(() => { if (!authLoading && user) { loadDashboardData(); } }, [user, authLoading]); const loadDashboardData = async () => { try { setLoading(true); const { data: { session }, } = await supabase.auth.getSession(); const token = session?.access_token; if (!token) throw new Error("No auth token"); try { const profileRes = await fetch(`${API_BASE}/api/devlink/profile`, { headers: { Authorization: `Bearer ${token}` }, }); if ( profileRes.ok && profileRes.headers.get("content-type")?.includes("application/json") ) { const data = await profileRes.json(); setProfile(data); } } catch (err) { // Silently ignore API errors } try { const oppRes = await fetch(`${API_BASE}/api/devlink/opportunities`, { headers: { Authorization: `Bearer ${token}` }, }); if ( oppRes.ok && oppRes.headers.get("content-type")?.includes("application/json") ) { const data = await oppRes.json(); setOpportunities(Array.isArray(data) ? data : []); } } catch (err) { // Silently ignore API errors } try { const teamsRes = await fetch(`${API_BASE}/api/devlink/teams`, { headers: { Authorization: `Bearer ${token}` }, }); if ( teamsRes.ok && teamsRes.headers.get("content-type")?.includes("application/json") ) { const data = await teamsRes.json(); setTeams(Array.isArray(data) ? data : []); } } catch (err) { // Silently ignore API errors } } catch (error) { // Silently ignore errors } finally { setLoading(false); } }; if (authLoading || loading) { return ; } if (!user) { return (

DEV-LINK

Roblox Developer Network

); } return (
{/* Header */}

DEV-LINK

Roblox Developer Network | Vibrant Cyan

{/* Tabs */} Overview Profile Editor Roblox Jobs Teams {/* Overview Tab */}

Profile Views

{profile?.profile_views || 0}

Job Matches

{opportunities.length}

Team Requests

{teams.length}

{/* Quick Links */}

Browse Roblox Jobs

Find a Teammate

{/* Profile Editor Tab */} My dev-link Profile Editor Customize your Roblox portfolio {/* Roblox Creations */}

My Roblox Creations

{isEditing ? (