import { useEffect, useState } from "react"; import { useParams, Link } from "react-router-dom"; import Layout from "@/components/Layout"; import SEO from "@/components/SEO"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; // API Base URL for fetch requests const API_BASE = import.meta.env.VITE_API_BASE || ""; import { Star, Mail, Music, Zap, Clock } from "lucide-react"; interface Artist { user_id: string; skills: string[]; for_hire: boolean; bio?: string; portfolio_url?: string; sample_price_track?: number; sample_price_sfx?: number; sample_price_score?: number; turnaround_days?: number; verified: boolean; total_downloads: number; created_at: string; user_profiles: { id: string; full_name: string; avatar_url?: string; email?: string; }; tracks: Array<{ id: string; title: string; genre: string[]; download_count: number; }>; } export default function ArtistProfile() { const { userId } = useParams<{ userId: string }>(); const [artist, setArtist] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const fetchArtist = async () => { if (!userId) return; try { const res = await fetch(`${API_BASE}/api/ethos/artists?id=${userId}`); const data = await res.json(); setArtist(data); } catch (error) { console.error("Failed to fetch artist:", error); } finally { setLoading(false); } }; fetchArtist(); }, [userId]); if (loading) { return (
Loading artist profile...
); } if (!artist) { return (
Artist not found
); } const memberSince = new Date(artist.created_at).toLocaleDateString("en-US", { year: "numeric", month: "short", }); return ( <>
{/* Profile Header */}
{artist.user_profiles.full_name.charAt(0)}

{artist.user_profiles.full_name}

{artist.verified && ( ✓ Verified Artist )}
{artist.bio && (

{artist.bio}

)}

Total Downloads

{artist.total_downloads}

Tracks Published

{artist.tracks.length}

Member Since

{memberSince}

{artist.for_hire && ( )}
{/* Skills & Services */}
{artist.skills.length > 0 && ( Skills
{artist.skills.map((skill) => ( {skill} ))}
)} {artist.for_hire && ( Services {artist.sample_price_track && (
Custom Track ${artist.sample_price_track}
)} {artist.sample_price_sfx && (
SFX Pack ${artist.sample_price_sfx}
)} {artist.sample_price_score && (
Full Score ${artist.sample_price_score}
)} {artist.turnaround_days && (
{artist.turnaround_days} day turnaround
)}
)}
{/* Portfolio */}

Portfolio

{artist.tracks.length === 0 ? ( No tracks published yet ) : (
{artist.tracks.map((track) => (

{track.title}

{track.genre.map((g) => ( {g} ))}
{track.download_count} downloads
))}
)}
); }