import React, { useEffect, useState } from 'react'; import { Link, useParams } from 'react-router-dom'; import { ArrowSquareOutIcon, CaretRightIcon, CircleNotchIcon, GlobeIcon, InstagramLogoIcon, LinkedinLogoIcon, YoutubeLogoIcon } from '@phosphor-icons/react'; import { Course } from '../types'; import { getPublicProfile, InstructorProfileData } from '../services/db'; import { CourseCoverImage } from '../components/CourseCoverImage'; import { CourseCard, Thumb } from '../components/catalog/Artwork'; import { Avatar } from '../components/ui/Avatar'; import { paths } from '../lib/routes'; import { useIsMobile } from '../hooks/useMediaQuery'; const networks = [ { key: 'websiteUrl', label: 'Site', icon: GlobeIcon }, { key: 'linkedinUrl', label: 'LinkedIn', icon: LinkedinLogoIcon }, { key: 'instagramUrl', label: 'Instagram', icon: InstagramLogoIcon }, { key: 'youtubeUrl', label: 'YouTube', icon: YoutubeLogoIcon }, ] as const; export const InstructorProfile: React.FC<{ onPlay: (course: Course) => void }> = () => { const { instructorId, profileId } = useParams<{ instructorId?: string; profileId?: string }>(); const id = instructorId || profileId; const isMobile = useIsMobile(); const [profile, setProfile] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { if (!id) return; setLoading(true); getPublicProfile(id).then(setProfile).catch(() => setProfile(null)).finally(() => setLoading(false)); }, [id]); if (loading) return
; if (!profile) return

Este perfil não está público.

; const isInstructor = profile.role === 'instructor' || profile.role === 'admin'; if (isMobile) return

{profile.name}

{profile.headline &&

{profile.headline}

}{profile.bio &&

{profile.bio}

}
{isInstructor &&

{profile.courses.length} {profile.courses.length === 1 ? 'curso' : 'cursos'}

{profile.courses.map((course) => {course.title}{course.lessons.length} aulas · {course.duration})}
}
; return
Professores{profile.name}
{profile.avatarImageUrl ? : }

{profile.name}

{profile.headline &&

{profile.headline}

}
{profile.bio &&

{profile.bio}

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

Cursos

{profile.courses.length}
{profile.courses.length ?
{profile.courses.map((course) => )}
:

Nenhum curso publicado ainda.

}
}
; };