diff --git a/src/components/content/courses/CourseSidebar.js b/src/components/content/courses/CourseSidebar.js index 3dcf2d0..a757233 100644 --- a/src/components/content/courses/CourseSidebar.js +++ b/src/components/content/courses/CourseSidebar.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React from 'react'; import { Tag } from 'primereact/tag'; import Image from 'next/image'; import { useImageProxy } from '@/hooks/useImageProxy'; @@ -11,26 +11,17 @@ const CourseSidebar = ({ completedLessons, isMobileView, onClose, - sidebarVisible: parentSidebarVisible, + sidebarVisible, 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); + // Only use the parent's state setter if (setSidebarVisible) { - setSidebarVisible(newState); + setSidebarVisible(!sidebarVisible); } }; @@ -86,7 +77,7 @@ const CourseSidebar = ({

Course Lessons

- {visible && !hideToggleButton && !isMobileView && ( + {sidebarVisible && !hideToggleButton && !isMobileView && ( {/* Mobile view - direct content instead of sidebar */} - {isMobileView && visible && ( + {isMobileView && sidebarVisible && ( )} @@ -135,7 +126,7 @@ const CourseSidebar = ({