import{r as b,u as S,b as v,j as e,L as C,e as k}from"./vendor-rThclpOQ.js";import{I as d}from"./input-error-Br4ngfdE.js";import{L as D}from"./loading-button-DKhpmf6V.js";import{B as t}from"./button-ZcsoqUQn.js";import{D as E,a as N,b as L,c as H,d as w}from"./dialog-CDEDwQhm.js";import{L as u}from"./label-CtY1vfZY.js";import{S as y,a as z,b as B,c as I,d as O}from"./select-u0okJC03.js";import{c as T}from"./utils-8KAaAB9H.js";import{j as V}from"./richtor-BYY1_E6w.js";import"./index-DquVdLUg.js";const K=()=>{const[m,r]=b.useState(!1),{props:i}=S(),n=i.auth.user,{exam:a}=i,p=["draft","published","archived"].filter(s=>s!==a.status),{data:l,post:h,setData:o,processing:x,errors:c,reset:g}=v({tab:"status",status:"",feedback:""}),j=s=>{s.preventDefault(),h(route("exams.update",a.id),{onSuccess:()=>{g(),r(!1)}})};return e.jsxs("div",{className:"flex flex-wrap items-center gap-4 md:gap-6",children:[e.jsx(t,{children:e.jsx(C,{href:route("exams.details",{slug:a.slug,id:a.id}),children:"View Exam"})}),e.jsx(t,{className:T("capitalize",a.status==="published"?"bg-green-500 hover:bg-green-600":a.status==="archived"?"bg-red-500 hover:bg-red-600":"bg-gray-500 hover:bg-gray-600"),disabled:!0,children:a.status}),n.role==="instructor"&&a.status!=="published"&&e.jsx(t,{onClick:()=>k.put(route("exams.status",{exam:a.id}),{status:"published"}),children:"Submit for Review"}),n.role==="admin"&&e.jsxs(E,{open:m,onOpenChange:r,children:[e.jsx(N,{asChild:!0,children:e.jsx(t,{className:"capitalize",children:"Change Status"})}),e.jsxs(L,{children:[e.jsx(H,{children:e.jsx(w,{children:"Change Exam Status"})}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Status"}),e.jsxs(y,{required:!0,value:l.status,onValueChange:s=>o("status",s),children:[e.jsx(z,{children:e.jsx(B,{placeholder:"Select status"})}),e.jsx(I,{children:p.map(s=>e.jsx(O,{value:s,className:"capitalize",children:s},s))})]}),e.jsx(d,{message:c.status})]}),e.jsxs("div",{className:"pb-6",children:[e.jsxs(u,{children:["Feedback ",e.jsx("span",{className:"text-gray-500",children:"(Optional)"})]}),e.jsx(V,{ssr:!0,output:"html",placeholder:{paragraph:"Enter feedback for instructor...",imageCaption:"Enter image caption..."},contentMinHeight:256,contentMaxHeight:640,initialContent:l.feedback,onContentChange:s=>o(f=>({...f,feedback:s}))}),e.jsx(d,{message:c.feedback})]}),e.jsx(D,{loading:x,className:"w-full",children:"Update Status"})]})]})]})]})};export{K as default};
