feat: add managed learning paths
All checks were successful
CI / Validate frontend and API (push) Successful in 41s
CI / Build and publish Docker images (push) Successful in 23s

This commit is contained in:
Cauê Faleiros
2026-09-04 16:22:09 -03:00
parent e18bb76630
commit 79d1c70c44
9 changed files with 358 additions and 337 deletions

View File

@@ -1,9 +1,10 @@
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { CourseRow } from './CourseRow';
import { Section, Course } from '../types';
import { getCourses } from '../services/db';
import { getCourses, getLearningPaths, PublicLearningPath } from '../services/db';
import { useAuth } from '../context/AuthContext';
import { Loader2, ChevronLeft, ChevronRight } from 'lucide-react';
import { LearningPathRow } from './LearningPathRow';
interface CourseGridProps {
onCourseSelect?: (course: Course) => void;
@@ -15,6 +16,7 @@ export const CourseGrid: React.FC<CourseGridProps> = ({
selectedCategoryFilter
}) => {
const [courses, setCourses] = useState<Course[]>([]);
const [paths, setPaths] = useState<PublicLearningPath[]>([]);
const [loading, setLoading] = useState(true);
const [activeCategory, setActiveCategory] = useState<string>('all');
const { user } = useAuth();
@@ -39,7 +41,9 @@ export const CourseGrid: React.FC<CourseGridProps> = ({
useEffect(() => {
const loadData = async () => {
try {
setCourses(await getCourses());
const [loadedCourses, loadedPaths] = await Promise.all([getCourses(), getLearningPaths()]);
setCourses(loadedCourses);
setPaths(loadedPaths);
} finally {
setLoading(false);
}
@@ -138,11 +142,6 @@ export const CourseGrid: React.FC<CourseGridProps> = ({
variant: 'landscape',
courses: courses.filter(c => (c.attachments && c.attachments.length > 0) || c.lessons.some(l => l.attachments && l.attachments.length > 0))
},
{
title: 'Formações Recomendadas',
variant: 'portrait',
courses: courses
}
];
return (
@@ -238,6 +237,7 @@ export const CourseGrid: React.FC<CourseGridProps> = ({
/>
)
))}
{activeCategory === 'all' && paths.length > 0 && <LearningPathRow paths={paths} courses={courses} onCourseSelect={onCourseSelect} />}
</section>
);
};