import React 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,
setSidebarVisible,
hideToggleButton = false,
}) => {
const { returnImageProxy } = useImageProxy();
const navbarHeight = 60; // Match the navbar height
const handleToggle = () => {
// Only use the parent's state setter
if (setSidebarVisible) {
setSidebarVisible(!sidebarVisible);
}
};
const LessonItem = ({ lesson, index }) => (
{
// Force full page refresh to trigger proper decryption
window.location.href = `/course/${window.location.pathname.split('/').pop()}?active=${index}`;
}}
>
{lesson.image && (
)}
Lesson {index + 1}
{completedLessons.includes(lesson.id) && (
)}
{lesson.title}
);
// Sidebar content component for reuse
const SidebarContent = () => (
Course Lessons
{sidebarVisible && !hideToggleButton && !isMobileView && (
)}
{lessons.map((lesson, index) => (
))}
);
// Mobile content tab
const MobileLessonsTab = () => (
Course Lessons
{lessons.map((lesson, index) => (
))}
);
return (
<>
{/* Mobile view - direct content instead of sidebar */}
{isMobileView && sidebarVisible && (
)}
{/* Desktop sidebar */}
{!isMobileView && (
{/* Adjusted to match new header spacing */}
)}
>
);
};
export default CourseSidebar;