var N=Object.defineProperty,k=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var h=(t,s,a)=>s in t?N(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,p=(t,s)=>{for(var a in s||(s={}))D.call(s,a)&&h(t,a,s[a]);if(u)for(var a of u(s))w.call(s,a)&&h(t,a,s[a]);return t},m=(t,s)=>k(t,E(s));import{r as H,aT as L,aU as y,j as e,aS as O,aX as T}from"./react-vendor-xYZnmIII.js";import{I as x}from"./input-error-_LAmvivg.js";import{L as z}from"./loading-button-D7aXR3K4.js";import{B as n,c as B,J as I,K as M,M as U,N as V,O as F,L as g,at as R,au as q,av as J,aw as K,ax as P}from"./ui-components-CQM92IK3.js";import{j as X}from"./richtor-BECSBxkh.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const se=()=>{const[t,s]=H.useState(!1),{props:a}=L(),l=a.auth.user,{exam:i}=a,j=["draft","published","archived"].filter(r=>r!==i.status),{data:o,post:f,setData:c,processing:b,errors:d,reset:S}=y({tab:"status",status:"",feedback:""}),v=r=>{r.preventDefault(),f(route("exams.update",i.id),{onSuccess:()=>{S(),s(!1)}})};return e.jsxs("div",{className:"flex flex-wrap items-center gap-4 md:gap-6",children:[e.jsx(n,{children:e.jsx(O,{href:route("exams.details",{slug:i.slug,id:i.id}),children:"View Exam"})}),e.jsx(n,{className:B("capitalize",i.status==="published"?"bg-green-500 hover:bg-green-600":i.status==="archived"?"bg-red-500 hover:bg-red-600":"bg-gray-500 hover:bg-gray-600"),disabled:!0,children:i.status}),l.role==="instructor"&&i.status!=="published"&&e.jsx(n,{onClick:()=>T.put(route("exams.status",{exam:i.id}),{status:"published"}),children:"Submit for Review"}),l.role==="admin"&&e.jsxs(I,{open:t,onOpenChange:s,children:[e.jsx(M,{asChild:!0,children:e.jsx(n,{className:"capitalize",children:"Change Status"})}),e.jsxs(U,{children:[e.jsx(V,{children:e.jsx(F,{children:"Change Exam Status"})}),e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Status"}),e.jsxs(R,{required:!0,value:o.status,onValueChange:r=>c("status",r),children:[e.jsx(q,{children:e.jsx(J,{placeholder:"Select status"})}),e.jsx(K,{children:j.map(r=>e.jsx(P,{value:r,className:"capitalize",children:r},r))})]}),e.jsx(x,{message:d.status})]}),e.jsxs("div",{className:"pb-6",children:[e.jsxs(g,{children:["Feedback ",e.jsx("span",{className:"text-gray-500",children:"(Optional)"})]}),e.jsx(X,{ssr:!0,output:"html",placeholder:{paragraph:"Enter feedback for instructor...",imageCaption:"Enter image caption..."},contentMinHeight:256,contentMaxHeight:640,initialContent:o.feedback,onContentChange:r=>c(C=>m(p({},C),{feedback:r}))}),e.jsx(x,{message:d.feedback})]}),e.jsx(z,{loading:b,className:"w-full",children:"Update Status"})]})]})]})]})};export{se as default};
