feat: finalize academy redesign and production readiness
All checks were successful
CI / Validate frontend and API (push) Successful in 2m22s
CI / Build and publish Docker images (push) Successful in 1m6s

Align admin, community, search, library, learning and course management with the mockup. Add saved courses, download history, public community feed, instructor directory, backend search, course views, admin content tools and community moderation. Harden API and Nginx for production.
This commit is contained in:
Cauê Faleiros
2026-11-05 15:06:53 -03:00
parent 95a4bd4ac7
commit 21085e887d
99 changed files with 10749 additions and 3935 deletions

View File

@@ -1,34 +1,38 @@
import React, { useEffect, useState } from 'react';
import { ExternalLink, Globe2, Instagram, Linkedin, Loader2, UserRound, Youtube } from 'lucide-react';
import { useParams } from 'react-router-dom';
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 } from '../components/CourseCard';
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: Globe2 },
{ key: 'linkedinUrl', label: 'LinkedIn', icon: Linkedin },
{ key: 'instagramUrl', label: 'Instagram', icon: Instagram },
{ key: 'youtubeUrl', label: 'YouTube', icon: Youtube },
{ 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 }> = ({ onPlay }) => {
export const InstructorProfile: React.FC<{ onPlay: (course: Course) => void }> = () => {
const { instructorId, profileId } = useParams<{ instructorId?: string; profileId?: string }>();
const publicProfileId = instructorId || profileId;
const id = instructorId || profileId;
const isMobile = useIsMobile();
const [profile, setProfile] = useState<InstructorProfileData | null>(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 <main className="min-h-[65vh] pt-32 flex items-center justify-center"><Loader2 className="h-8 w-8 animate-spin text-orange-400" /></main>;
if (state === 'missing' || !profile) return <main className="mx-auto flex min-h-[65vh] max-w-5xl items-center px-6 pt-24"><div><p className="text-sm font-semibold uppercase tracking-widest text-orange-400">Perfil indisponível</p><h1 className="mt-3 text-3xl font-bold">Este perfil não está público.</h1></div></main>;
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 <main className="wrap page"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
if (!profile) return <main className="wrap page"><p className="empty">Este perfil não está público.</p></main>;
const isInstructor = profile.role === 'instructor' || profile.role === 'admin';
return <main className="min-h-screen pb-20 pt-20"><section className="border-b border-white/10 bg-gradient-to-br from-orange-500/15 via-zinc-950 to-black"><div className="mx-auto grid max-w-6xl gap-7 px-6 py-12 sm:px-8 md:grid-cols-[auto_1fr] md:items-center md:py-16"><div className="h-32 w-32 overflow-hidden rounded-full border-4 border-zinc-900 bg-zinc-800 shadow-2xl shadow-black/50">{profile.avatarImageUrl ? <CourseCoverImage source={profile.avatarImageUrl} alt={`Foto de ${profile.name}`} className="h-full w-full object-cover" /> : <div className="flex h-full w-full items-center justify-center bg-orange-500/15"><UserRound className="h-14 w-14 text-orange-300" /></div>}</div><div><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">{isInstructor ? 'Instrutor' : 'Aluno'}</p><h1 className="mt-2 text-3xl font-bold tracking-tight text-white sm:text-5xl">{profile.name}</h1>{profile.headline && <p className="mt-3 text-lg text-gray-300">{profile.headline}</p>}<div className="mt-5 flex flex-wrap gap-2">{networks.map(({ key, label, icon: Icon }) => { const url = profile[key]; return url ? <a key={key} href={url} target="_blank" rel="noreferrer" className="inline-flex items-center gap-2 rounded-xl border border-white/15 bg-white/5 px-3.5 py-2 text-sm font-semibold text-white transition hover:border-orange-500/40 hover:bg-orange-500/10"><Icon className="h-4 w-4 text-orange-400" />{label}<ExternalLink className="h-3 w-3 text-gray-500" /></a> : null; })}</div></div></div></section><div className={`mx-auto max-w-6xl gap-12 px-6 py-12 sm:px-8 ${isInstructor ? 'grid lg:grid-cols-[minmax(0,0.7fr)_minmax(0,1.3fr)]' : 'max-w-3xl'}`}><aside><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Sobre</p><h2 className="mt-2 text-2xl font-bold text-white">Conheça {profile.name.split(' ')[0]}</h2><p className="mt-5 whitespace-pre-line text-sm leading-7 text-gray-300">{profile.bio || `${isInstructor ? 'Este instrutor' : 'Este aluno'} ainda não adicionou uma apresentação.`}</p></aside>{isInstructor && <section><div className="mb-6 flex items-end justify-between gap-4"><div><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Conteúdo</p><h2 className="mt-2 text-2xl font-bold text-white">Cursos publicados</h2></div><span className="rounded-full bg-white/5 px-3 py-1.5 text-xs font-semibold text-gray-300">{profile.courses.length} {profile.courses.length === 1 ? 'curso' : 'cursos'}</span></div>{profile.courses.length ? <div className="grid gap-7 sm:grid-cols-2">{profile.courses.map((course) => <CourseCard key={course.id} course={course} variant="landscape" onClick={onPlay} />)}</div> : <div className="rounded-2xl border border-dashed border-white/15 p-8 text-center text-sm text-gray-500">Nenhum curso publicado ainda.</div>}</section>}</div></main>;
if (isMobile) return <main className="m-page m-gut enter"><header className="m-person"><Avatar name={profile.name} src={profile.avatarImageUrl || undefined} size="xl" /><h1>{profile.name}</h1>{profile.headline && <p>{profile.headline}</p>}{profile.bio && <p className="m-body">{profile.bio}</p>}</header>
{isInstructor && <section className="m-group"><h2>{profile.courses.length} {profile.courses.length === 1 ? 'curso' : 'cursos'}</h2><div className="m-list">{profile.courses.map((course) => <Link className="m-row" key={course.id} to={paths.course(course.id)}><Thumb course={course} /><span className="m-rt"><b>{course.title}</b><small>{course.lessons.length} aulas · {course.duration}</small></span><CaretRightIcon className="m-chev" /></Link>)}</div></section>}
</main>;
return <main className="wrap page enter"><div className="crumb"><Link to={paths.professors}>Professores</Link><CaretRightIcon className="ph" /><span>{profile.name}</span></div>
<header className="profile-head">{profile.avatarImageUrl ? <span className="av xl"><CourseCoverImage source={profile.avatarImageUrl} alt={`Foto de ${profile.name}`} /></span> : <Avatar name={profile.name} size="xl" />}<div><h1>{profile.name}</h1>{profile.headline && <p>{profile.headline}</p>}</div></header>
{profile.bio && <p className="profile-bio">{profile.bio}</p>}
<div className="profile-links">{networks.map(({ key, label, icon: Icon }) => { const url = profile[key]; return url ? <a className="btn sec" key={key} href={url} target="_blank" rel="noreferrer"><Icon className="ph" />{label}<ArrowSquareOutIcon className="ph" /></a> : null; })}</div>
{isInstructor && <section className="shelf"><header><h2>Cursos</h2><span className="count num">{profile.courses.length}</span></header>{profile.courses.length ? <div className="grid">{profile.courses.map((course) => <CourseCard key={course.id} course={course} />)}</div> : <p className="empty">Nenhum curso publicado ainda.</p>}</section>}
</main>;
};