import{c as E,r as m,u as $,a as A,j as a,B as F}from"./index-7c7a558c.js";import{o as R}from"./studentApi-6e4fac08.js";import{R as T}from"./index-fbc7cd92.js";const k=()=>{var x,e,h,g,r,p,j,b;const o=E(),[y,w]=m.useState(0),l=$(),f=l==null?void 0:l.slug,{data:i,isLoading:S}=A("getSingleCourse",()=>R(f)),[s,C]=m.useState({});return m.useEffect(()=>{const t=localStorage.getItem("token"),n=localStorage.getItem("user");t&&n||o("/login")},[o]),a.jsx(a.Fragment,{children:!S&&((e=(x=i==null?void 0:i.data)==null?void 0:x.data)!=null&&e.course_lessons)?a.jsx("div",{className:"container mx-auto my-5 lg:p-5",children:a.jsx("div",{className:"relative overflow-x-auto shadow-md sm:rounded-lg",children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 p-6",children:[a.jsxs("div",{className:"my-6",children:[a.jsx("h1",{className:"p-4 rounded bg-blue-600 text-white text-xl my-4",children:"Course Lecture Details"}),a.jsx("div",{className:"my-6",children:s!=null&&s.id?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"my-4",children:["Title: ",s==null?void 0:s.title]}),s!=null&&s.id&&(s==null?void 0:s.type)=="youtube"?a.jsx(T,{url:`https://www.youtube.com/watch?v=${s==null?void 0:s.url_path}`,controls:!0,width:"100%"}):(s==null?void 0:s.type)=="text"?a.jsx("p",{children:s==null?void 0:s.text}):(s==null?void 0:s.type)=="image"&&a.jsx("img",{src:`${F}${s==null?void 0:s.image}`,width:100})]}):"No topic selected yet!"})]}),a.jsx("div",{className:"my-6",children:a.jsxs("div",{className:"p-4",children:[a.jsx("h1",{className:"p-4 rounded bg-blue-600 text-white text-xl mb-6",children:"Course Lessons"}),((r=(g=(h=i==null?void 0:i.data)==null?void 0:h.data)==null?void 0:g.course_lessons)==null?void 0:r.length)!=0?(b=(j=(p=i==null?void 0:i.data)==null?void 0:p.data)==null?void 0:j.course_lessons)==null?void 0:b.map((t,n)=>{var N;return a.jsxs("div",{children:[a.jsx("h1",{className:"p-2 rounded bg-blue-600 text-white text-lg cursor-pointer",onClick:()=>w(d=>d==n?!1:n),children:t==null?void 0:t.name}),a.jsx("div",{className:`my-6 px-4 ${y==n?"block":"hidden"}`,children:(N=t==null?void 0:t.lectures)==null?void 0:N.map((d,c)=>a.jsxs("div",{className:`flex justify-between items-center my-2 bg-blue-500 p-2 text-white cursor-pointer ${(d==null?void 0:d.id)==(s==null?void 0:s.id)&&"font-bold"}`,onClick:()=>C(d),children:[a.jsx("p",{children:d==null?void 0:d.title}),a.jsx("p",{children:d==null?void 0:d.type})]},c+n))})]},n)}):a.jsx(a.Fragment,{children:"No Lessons here"})]})})]})})}):a.jsx(a.Fragment,{children:"Loading..."})})};export{k as default};
