var D=Object.defineProperty,E=Object.defineProperties;var w=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var u=(r,t,a)=>t in r?D(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a,h=(r,t)=>{for(var a in t||(t={}))H.call(t,a)&&u(r,a,t[a]);if(d)for(var a of d(t))L.call(t,a)&&u(r,a,t[a]);return r},g=(r,t)=>E(r,w(t));import{jsxs as o,jsx as e}from"react/jsx-runtime";import{I as f}from"./input-error-BbsDx4-P.js";import{L as y}from"./loading-button-B_LaGOAp.js";import{B as n,c as z,H as B,J as I,K as M,M as O,N as T,L as b,as as V,at as j,au as F,av as U,aw as q}from"./ui-components-B24mpb8o.js";import{usePage as J,useForm as K,Link as P,router as R}from"@inertiajs/react";import{useState as A}from"react";import{Editor as G}from"richtor";/* empty css                */import"lucide-react";import"next-themes";import"sonner";import"@radix-ui/react-label";import"class-variance-authority";import"@radix-ui/react-checkbox";import"@radix-ui/react-avatar";import"@radix-ui/react-dropdown-menu";import"@radix-ui/react-scroll-area";import"@radix-ui/react-popover";import"@radix-ui/react-radio-group";import"@radix-ui/react-dialog";import"@radix-ui/react-slot";import"clsx";import"@radix-ui/react-separator";import"@radix-ui/react-tooltip";import"@radix-ui/react-tabs";import"@radix-ui/react-accordion";import"@radix-ui/react-progress";import"@radix-ui/react-select";import"cmdk";import"@radix-ui/react-switch";import"react-day-picker";import"@radix-ui/react-slider";import"embla-carousel-react";import"@radix-ui/react-toggle-group";import"vaul";import"tailwind-merge";const ze=()=>{const[r,t]=A(!1),{props:a}=J(),l=a.auth.user,{exam:s}=a,x=["draft","published","archived"].filter(i=>i!==s.status),{data:m,post:S,setData:p,processing:v,errors:c,reset:C}=K({tab:"status",status:"",feedback:""}),N=i=>{i.preventDefault(),S(route("exams.update",s.id),{onSuccess:()=>{C(),t(!1)}})};return o("div",{className:"flex flex-wrap items-center gap-4 md:gap-6",children:[e(n,{children:e(P,{href:route("exams.details",{slug:s.slug,id:s.id}),children:"View Exam"})}),e(n,{className:z("capitalize",s.status==="published"?"bg-green-500 hover:bg-green-600":s.status==="archived"?"bg-red-500 hover:bg-red-600":"bg-gray-500 hover:bg-gray-600"),disabled:!0,children:s.status}),l.role==="instructor"&&s.status!=="published"&&e(n,{onClick:()=>R.put(route("exams.status",{exam:s.id}),{status:"published"}),children:"Submit for Review"}),l.role==="admin"&&o(B,{open:r,onOpenChange:t,children:[e(I,{asChild:!0,children:e(n,{className:"capitalize",children:"Change Status"})}),o(M,{children:[e(O,{children:e(T,{children:"Change Exam Status"})}),o("form",{onSubmit:N,className:"space-y-4",children:[o("div",{children:[e(b,{children:"Status"}),o(V,{required:!0,value:m.status,onValueChange:i=>p("status",i),children:[e(j,{children:e(F,{placeholder:"Select status"})}),e(U,{children:x.map(i=>e(q,{value:i,className:"capitalize",children:i},i))})]}),e(f,{message:c.status})]}),o("div",{className:"pb-6",children:[o(b,{children:["Feedback ",e("span",{className:"text-gray-500",children:"(Optional)"})]}),e(G,{ssr:!0,output:"html",placeholder:{paragraph:"Enter feedback for instructor...",imageCaption:"Enter image caption..."},contentMinHeight:256,contentMaxHeight:640,initialContent:m.feedback,onContentChange:i=>p(k=>g(h({},k),{feedback:i}))}),e(f,{message:c.feedback})]}),e(y,{loading:v,className:"w-full",children:"Update Status"})]})]})]})]})};export{ze as default};
