import Layout from "@/components/Layout"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { useParams, useNavigate } from "react-router-dom"; import { useEffect, useState } from "react"; import { Github, Globe, Mail, ArrowLeft, ExternalLink, MessageSquare, Share2, MapPin, Trophy, Briefcase, } from "lucide-react"; import { supabase } from "@/lib/supabase"; interface DevProfile { id: string; user_id: string; full_name: string; avatar_url?: string; bio?: string; skills: string[]; experience_level: "beginner" | "intermediate" | "advanced" | "expert"; looking_for?: string; portfolio_url?: string; github_url?: string; email?: string; city?: string; country?: string; created_at: string; } export default function DevLinkProfile() { const { profileId } = useParams<{ profileId: string }>(); const navigate = useNavigate(); const [profile, setProfile] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchProfile = async () => { if (!profileId) { setError("Profile not found"); setLoading(false); return; } try { const { data, error: fetchError } = await supabase .from("profiles") .select("*") .eq("id", profileId) .single(); if (fetchError) throw fetchError; const devProfile: DevProfile = { id: data.id, user_id: data.user_id, full_name: data.full_name || "Anonymous Developer", avatar_url: data.avatar_url, bio: data.bio, skills: data.interests || [], experience_level: data.experience_level || "intermediate", looking_for: data.looking_for, portfolio_url: data.portfolio_url, github_url: data.github_url, email: data.email, city: data.city, country: data.country, created_at: data.created_at, }; setProfile(devProfile); } catch (err) { console.error("Error fetching profile:", err); setError("Failed to load profile"); } finally { setLoading(false); } }; fetchProfile(); }, [profileId]); const getExperienceColor = (level: string) => { const colors: Record = { beginner: "bg-blue-500/20 text-blue-300 border-blue-400/40", intermediate: "bg-cyan-500/20 text-cyan-300 border-cyan-400/40", advanced: "bg-violet-500/20 text-violet-300 border-violet-400/40", expert: "bg-amber-500/20 text-amber-300 border-amber-400/40", }; return colors[level] || colors.intermediate; }; if (loading) { return (

Loading profile...

); } if (error || !profile) { return (

{error || "Profile not found"}

); } return (
{/* Animated backgrounds */}
{/* Header */}
Dev-Link
{/* Profile Card */}
{profile.avatar_url && ( {profile.full_name} )}
{profile.full_name} {profile.experience_level} Developer
{(profile.city || profile.country) && (
{profile.city && profile.country ? `${profile.city}, ${profile.country}` : profile.city || profile.country}
)}
{/* Bio */} {profile.bio && (

About

{profile.bio}

)} {/* Looking For */} {profile.looking_for && (

Currently Looking For

{profile.looking_for}

)} {/* Skills */} {profile.skills && profile.skills.length > 0 && (

Skills

{profile.skills.map((skill) => ( {skill} ))}
)} {/* Links */} {(profile.github_url || profile.portfolio_url || profile.email) && (

Connect

{profile.github_url && ( GitHub )} {profile.portfolio_url && ( Portfolio )} {profile.email && ( Email )}
)} {/* Member Since */}

Member since{" "} {new Date(profile.created_at).toLocaleDateString()}

); }