fix: useState hook error in catalog + add certificate download in learning page

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
root
2026-02-06 10:55:24 +00:00
parent 5ddb3db1ac
commit bed7e440c1
3 changed files with 118 additions and 3 deletions

View File

@ -34,6 +34,7 @@ export default function PublicCoursePage() {
const [loading, setLoading] = useState(true);
const [enrolling, setEnrolling] = useState(false);
const [enrolled, setEnrolled] = useState(false);
const [expandedChapters, setExpandedChapters] = useState<string[]>([]);
useEffect(() => {
if (!id) return;
@ -221,12 +222,19 @@ export default function PublicCoursePage() {
<h2 className="text-xl font-semibold mb-4">Содержание курса</h2>
<div className="space-y-2">
{course.chapters.map((chapter: any) => {
const [expanded, setExpanded] = useState(false);
const expanded = expandedChapters.includes(chapter.id);
const toggleExpanded = () => {
setExpandedChapters(prev =>
prev.includes(chapter.id)
? prev.filter(id => id !== chapter.id)
: [...prev, chapter.id]
);
};
return (
<div key={chapter.id} className="border rounded-lg overflow-hidden">
<button
className="flex items-center justify-between w-full p-4 hover:bg-muted/50 transition-colors"
onClick={() => setExpanded(!expanded)}
onClick={toggleExpanded}
>
<div className="flex items-center gap-3">
<BookOpen className="h-4 w-4 text-primary" />