fix: useState hook error in catalog + add certificate download in learning page
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user