feat: add managed learning paths
This commit is contained in:
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user