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 }) => (