import{r as B,u as E,b as I,j as e,L as _,e as f}from"./vendor-rThclpOQ.js";import{I as b}from"./input-error-Br4ngfdE.js";import{L as T}from"./loading-button-DKhpmf6V.js";import{B as i}from"./button-ZcsoqUQn.js";import{D as v,a as y,b as C,c as M,d as V}from"./dialog-CDEDwQhm.js";import{L as N}from"./label-CtY1vfZY.js";import{S as F,a as P,b as R,c as U,d as A}from"./select-u0okJC03.js";import{c as G}from"./utils-8KAaAB9H.js";import{j as J}from"./richtor-BYY1_E6w.js";import"./index-DquVdLUg.js";const ae=()=>{const[h,l]=B.useState(!1),{props:n}=E(),{translate:S}=n,{dashboard:a,button:r,input:d,common:m}=S,k=n.auth.user,{course:t,watchHistory:o,approvalStatus:w}=n,z=n.statuses.filter(s=>s!==t.status),{approve_able:u,validation_messages:D,counts:c}=w,{data:x,put:H,setData:j,processing:L,errors:g,reset:O}=I({status:"",feedback:""}),q=s=>{s.preventDefault(),H(route("course.status",{id:t.id}),{onSuccess:()=>{O(),l(!1)}})};return e.jsxs("div",{className:"flex flex-wrap items-center gap-4 md:gap-6",children:[e.jsx(i,{children:e.jsx(_,{href:route("course.details",{slug:t.slug,id:t.id}),children:r.course_preview})}),o?e.jsx(i,{children:e.jsx(_,{href:route("course.player",{type:o.current_watching_type,watch_history:o.id,lesson_id:o.current_watching_id}),children:r.course_player})}):u?e.jsx(i,{onClick:()=>f.post(route("player.init.watch-history"),{course_id:t.id}),children:r.course_player}):e.jsx(i,{disabled:!0,children:r.course_player}),e.jsx(i,{className:G("capitalize",t.status==="approved"?"bg-green-500":t.status==="rejected"?"bg-red-500":"bg-gray-500"),disabled:!0,children:t.status}),u?k.role==="instructor"?t.status!=="approved"&&t.status!=="pending"&&e.jsx(i,{onClick:()=>f.put(route("course.status",{id:t.id}),{status:"pending"}),children:r.submit_for_approval}):e.jsxs(v,{open:h,onOpenChange:l,children:[e.jsx(y,{asChild:!0,children:e.jsx(i,{className:"capitalize",children:r.approval_status})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(N,{children:m.status}),e.jsxs(F,{required:!0,value:x.status,onValueChange:s=>j("status",s),children:[e.jsx(P,{className:"capitalize",children:e.jsx(R,{placeholder:m.select_the_approval_status})}),e.jsx(U,{children:z.map(s=>e.jsx(A,{value:s,className:"cursor-pointer capitalize",children:s},s))})]}),e.jsx(b,{message:g.status})]}),e.jsxs("div",{className:"pb-6",children:[e.jsxs(N,{children:[d.feedback," ","(Optional)"]}),e.jsx(J,{ssr:!0,output:"html",placeholder:{paragraph:d.description_placeholder,imageCaption:d.image_url_placeholder},contentMinHeight:256,contentMaxHeight:640,initialContent:x.feedback,onContentChange:s=>j(p=>({...p,feedback:s}))}),e.jsx(b,{message:g.feedback})]}),e.jsx(T,{loading:L,className:"w-full",children:r.submit})]})})]}):e.jsxs(v,{open:h,onOpenChange:l,children:[e.jsx(y,{children:e.jsx(i,{children:r.submit_for_approval})}),e.jsxs(C,{children:[e.jsx(M,{children:e.jsx(V,{children:a.course_approval_status})}),u?e.jsx("div",{className:"text-green-600",children:a.course_ready_approval}):e.jsxs("div",{className:"text-red-600",children:[e.jsx("h3",{children:a.course_needs_attention}),e.jsx("ul",{className:"list-disc pl-5",children:D.map((s,p)=>e.jsx("li",{children:s},p))})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:a.course_content_summary}),e.jsxs("p",{children:[a.sections,": ",c.sections_count]}),e.jsxs("p",{children:[a.lessons,": ",c.lessons_count]}),e.jsxs("p",{children:[a.quizzes,": ",c.quizzes_count]}),e.jsxs("p",{className:"font-medium",children:[a.total_content_items,": ",c.total_content_count]})]})]})]})]})};export{ae as default};
