'use client';
import React, { useContext } from 'react';
import { Card, CardContent } from "@/components/ui/card";
import { Progress } from "@/components/ui/progress";
import CourseDetailHeroSection from './CourseDetailHeroSection';
import CourseDetailStats from './CourseDetailStats';
import CourseMedia from './CourseMedia';
import CourseProgress from './CourseProgress';
import TryPDF  from './TryPDF';
import { CourseData } from '@/helpers/apiSchema/course.schema';
import useSWR from 'swr';
import { APP_BASE_URL } from '@/utils/constants';
import { defaultFetcher } from '@/helpers/fetch.helper';
import { AuthContext, AuthProvider } from '@/helpers/context/AuthProvider';

const CourseIndividualContentWrapper : React.FC<{
    course_uuid : string
}> = ({
    course_uuid
}) => {

    const { user } = useContext(AuthContext)
    const  { data , mutate } = useSWR(APP_BASE_URL + `/api/course/info/${course_uuid}` , defaultFetcher)


    return (
        <div className="min-h-screen bg-gray-50">
            {/* Hero Section */}
            <CourseDetailHeroSection courseData={data?.data as CourseData} mutate={mutate}/>

            {/* Course Stats */}
            <CourseDetailStats courseData={data?.data}/>

            {
                user && data?.data?.selfEnrollment?.isEnrolled &&  (
                    
                    <CourseProgress courseData={data?.data}/>
                )
            }


            {/* Course Content */}
            <CourseMedia courseData={data?.data}/>
            
        </div>
    );
};

export default CourseIndividualContentWrapper;