Files
compor-academy/pages/ExplorePage.tsx
Cauê Faleiros 21085e887d
All checks were successful
CI / Validate frontend and API (push) Successful in 2m22s
CI / Build and publish Docker images (push) Successful in 1m6s
feat: finalize academy redesign and production readiness
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.
2026-11-05 15:06:53 -03:00

49 lines
2.2 KiB
TypeScript

import React from 'react';
import { CircleNotchIcon } from '@phosphor-icons/react';
import { Hero } from '../components/catalog/Hero';
import { Shelf } from '../components/catalog/Shelf';
import { ContinueCard, CourseCard, TrailPoster } from '../components/catalog/Artwork';
import { useCatalog } from '../context/CatalogContext';
import { useAuth } from '../context/AuthContext';
import { paths } from '../lib/routes';
import { useIsMobile } from '../hooks/useMediaQuery';
export const ExplorePage: React.FC = () => {
const { courses, paths: trails, areas, isLoading, failed } = useCatalog();
const { user } = useAuth();
const isMobile = useIsMobile();
const going = user ? courses.filter((course) => (course.progress || 0) > 0 && (course.progress || 0) < 100) : [];
const mostWatched = courses.length > 0 && (
<Shelf title="Mais assistidos" to={paths.search}>
{[...courses].sort((a, b) => (b.views || 0) - (a.views || 0)).slice(0, 10).map((course) => <CourseCard key={course.id} course={course} />)}
</Shelf>
);
const trailsShelf = trails.length > 0 && (
<Shelf title="Trilhas" to={paths.trails} kind="tall">
{trails.map((trail) => <TrailPoster key={trail.id} path={trail} />)}
</Shelf>
);
return (
<>
<Hero />
<main className="wrap page has-hero enter">
{isLoading && <div className="loading"><CircleNotchIcon className="ph spin" /></div>}
{!isLoading && failed && <p className="empty">Não foi possível carregar os cursos. Tente novamente em instantes.</p>}
{!isLoading && !failed && courses.length === 0 && <p className="empty">Ainda não há cursos publicados.</p>}
{going.length > 0 && (
<Shelf title="Continue assistindo" to={paths.learning} kind="wide">
{going.map((course) => <ContinueCard key={course.id} course={course} />)}
</Shelf>
)}
{isMobile ? <>{trailsShelf}{mostWatched}</> : <>{mostWatched}{trailsShelf}</>}
{areas.map((area) => (
<Shelf key={area} title={area} to={`${paths.search}?area=${encodeURIComponent(area)}`}>
{courses.filter((course) => course.category === area).map((course) => <CourseCard key={course.id} course={course} />)}
</Shelf>
))}
</main>
</>
);
};