import React, { useState, useEffect } from 'react'; import { Tag } from 'primereact/tag'; import Image from 'next/image'; import { useImageProxy } from '@/hooks/useImageProxy'; import GenericButton from '@/components/buttons/GenericButton'; const CourseSidebar = ({ lessons, activeIndex, onLessonSelect, completedLessons, isMobileView, onClose, sidebarVisible: parentSidebarVisible, setSidebarVisible, hideToggleButton = false, }) => { const { returnImageProxy } = useImageProxy(); const [visible, setVisible] = useState(true); const navbarHeight = 60; // Match the navbar height // Sync with parent state if provided useEffect(() => { if (typeof parentSidebarVisible !== 'undefined') { setVisible(parentSidebarVisible); } }, [parentSidebarVisible]); const handleToggle = () => { const newState = !visible; setVisible(newState); if (setSidebarVisible) { setSidebarVisible(newState); } }; const LessonItem = ({ lesson, index }) => (
  • onLessonSelect(index)} >
    {lesson.image && (
    {`Lesson
    )}
    Lesson {index + 1} {completedLessons.includes(lesson.id) && ( )}

    {lesson.title}

  • ); // Sidebar content component for reuse const SidebarContent = () => (

    Course Lessons

    {visible && !hideToggleButton && !isMobileView && ( )}
    ); // Mobile content tab const MobileLessonsTab = () => (

    Course Lessons

    ); return ( <> {/* Mobile view - direct content instead of sidebar */} {isMobileView && visible && ( )} {/* Desktop sidebar */} {!isMobileView && (
    {/* Adjusted to match new header spacing */}
    )} ); }; export default CourseSidebar;