import LessonIcons from '@/components/lesson-icons'; import { cn } from '@/lib/utils'; import { StudentCourseProps } from '@/types/page'; import { Link, usePage } from '@inertiajs/react'; import { ReactNode } from 'react'; interface Props { lesson: SectionLesson; completed: { id: number | string; type: string }[]; } const LessonWrapper = ({ lesson, children }: { lesson: SectionLesson; children: ReactNode }) => (
{children} {['video', 'video_url'].includes(lesson.lesson_type) && ( {lesson.duration} )}
); const Lesson = ({ lesson, completed }: Props) => { const { props } = usePage(); const { course, watchHistory } = props; const dripContent = Boolean(course.drip_content); const isNext = lesson.id == watchHistory.next_watching_id; const isCompleted = completed.some((item) => item.type === 'lesson' && item.id == lesson.id); const isCurrentLesson = watchHistory.current_watching_id == lesson.id; return !dripContent ? (

{lesson.title}

) : ( <> {isCompleted || isCurrentLesson || isNext ? (

{lesson.title}

) : (

{lesson.title}

)} ); }; export default Lesson;