import React, { useEffect, useState } from 'react'; import { ExternalLink, Globe2, Instagram, Linkedin, Loader2, UserRound, Youtube } from 'lucide-react'; import { useParams } from 'react-router-dom'; import { Course } from '../types'; import { getPublicProfile, InstructorProfileData } from '../services/db'; import { CourseCoverImage } from '../components/CourseCoverImage'; import { CourseCard } from '../components/CourseCard'; const networks = [ { key: 'websiteUrl', label: 'Site', icon: Globe2 }, { key: 'linkedinUrl', label: 'LinkedIn', icon: Linkedin }, { key: 'instagramUrl', label: 'Instagram', icon: Instagram }, { key: 'youtubeUrl', label: 'YouTube', icon: Youtube }, ] as const; export const InstructorProfile: React.FC<{ onPlay: (course: Course) => void }> = ({ onPlay }) => { const { instructorId, profileId } = useParams<{ instructorId?: string; profileId?: string }>(); const publicProfileId = instructorId || profileId; const [profile, setProfile] = useState(null); const [state, setState] = useState<'loading' | 'ready' | 'missing'>('loading'); useEffect(() => { if (!publicProfileId) return; setState('loading'); getPublicProfile(publicProfileId).then((data) => { setProfile(data); setState('ready'); }).catch(() => setState('missing')); }, [publicProfileId]); if (state === 'loading') return
; if (state === 'missing' || !profile) return

Perfil indisponível

Este perfil não está público.

; const isInstructor = profile.role === 'instructor' || profile.role === 'admin'; return
{profile.avatarImageUrl ? :
}

{isInstructor ? 'Instrutor' : 'Aluno'}

{profile.name}

{profile.headline &&

{profile.headline}

}
{networks.map(({ key, label, icon: Icon }) => { const url = profile[key]; return url ? {label} : null; })}
{isInstructor &&

Conteúdo

Cursos publicados

{profile.courses.length} {profile.courses.length === 1 ? 'curso' : 'cursos'}
{profile.courses.length ?
{profile.courses.map((course) => )}
:
Nenhum curso publicado ainda.
}
}
; };