diff --git a/App.tsx b/App.tsx index 8a329c9..f405eeb 100644 --- a/App.tsx +++ b/App.tsx @@ -97,6 +97,7 @@ function AppContent() { } /> } /> } /> + } /> } /> } /> diff --git a/pages/InstructorProfile.tsx b/pages/InstructorProfile.tsx index 15d5541..245f039 100644 --- a/pages/InstructorProfile.tsx +++ b/pages/InstructorProfile.tsx @@ -2,7 +2,7 @@ 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 { getInstructorProfile, InstructorProfileData } from '../services/db'; +import { getPublicProfile, InstructorProfileData } from '../services/db'; import { CourseCoverImage } from '../components/CourseCoverImage'; import { CourseCard } from '../components/CourseCard'; @@ -14,18 +14,21 @@ const networks = [ ] as const; export const InstructorProfile: React.FC<{ onPlay: (course: Course) => void }> = ({ onPlay }) => { - const { instructorId } = useParams<{ instructorId: string }>(); + 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 (!instructorId) return; + if (!publicProfileId) return; setState('loading'); - getInstructorProfile(instructorId).then((data) => { setProfile(data); setState('ready'); }).catch(() => setState('missing')); - }, [instructorId]); + 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.

; - return
{profile.avatarImageUrl ? :
}

Instrutor

{profile.name}

{profile.headline &&

{profile.headline}

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

Conteúdo

Cursos publicados

{profile.courses.length} {profile.courses.length === 1 ? 'curso' : 'cursos'}
{profile.courses.length ?
{profile.courses.map((course) => )}
:
Nenhum curso publicado ainda.
}
; + 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.
}
}
; }; diff --git a/pages/ProfilePage.tsx b/pages/ProfilePage.tsx index 4a81b0e..7c02aef 100644 --- a/pages/ProfilePage.tsx +++ b/pages/ProfilePage.tsx @@ -33,8 +33,6 @@ export const ProfilePage: React.FC = () => { const [isSaving, setIsSaving] = useState(false); const [isUploading, setIsUploading] = useState(false); - const canPublishProfile = user?.role === 'professor' || user?.role === 'superadmin'; - useEffect(() => { if (!user) return; profileApi.me() @@ -102,9 +100,9 @@ export const ProfilePage: React.FC = () => {

Sua conta

Meu perfil

-

{canPublishProfile ? 'Apresente sua experiência e conecte os alunos aos seus cursos.' : 'Mantenha seus dados pessoais atualizados.'}

+

Apresente quem você é, compartilhe seus links e escolha a visibilidade do seu perfil.

- {canPublishProfile && profile.isPublic && } + {profile.isPublic && }
@@ -112,9 +110,9 @@ export const ProfilePage: React.FC = () => {
{profile.avatarImageUrl ? :
} - {canPublishProfile && } +
-

{profile.name}

{user.email}

{canPublishProfile &&

A foto e a apresentação ficam visíveis no seu perfil público.

}
+

{profile.name}

{user.email}

A foto e a apresentação ficam visíveis quando seu perfil estiver público.

{ void uploadAvatar(event.target.files?.[0]); event.currentTarget.value = ''; }} /> @@ -122,13 +120,11 @@ export const ProfilePage: React.FC = () => {
- {canPublishProfile && <> - -