2 lines
3.4 KiB
JavaScript
2 lines
3.4 KiB
JavaScript
import{u as V,b as T,r as B,j as e}from"./vendor-BKmmeuxg.js";import{C as m}from"./combobox-Byd5-E0j.js";import{I as o}from"./input-error-LaPr_4wd.js";import{L as H}from"./loading-button-BnTVAMJ7.js";import{C as M}from"./card-D9_SJYq6.js";import{I as k}from"./input-DM0goJrn.js";import{L as n}from"./label-HmIcv5Yx.js";import{S as p,a as x,b as h,c as u,d as j}from"./select-CD9o3HN1.js";import{T as z}from"./textarea-CyndvowL.js";import{o as g}from"./inertia-SZXqLvQm.js";import{k as w}from"./richtor-CRcM6Du2.js";import"./button-BpNwv2aE.js";import"./index-WW_1X1qx.js";import"./utils-DxSsnXxD.js";import"./popover-B4kBsMuI.js";const $=()=>{const{props:v}=V(),{auth:f,system:S,tab:_,categories:l,exam:t,instructors:c}=v,{data:a,setData:r,post:C,errors:i,processing:b}=T({tab:_,title:t.title||"",short_description:t.short_description||"",description:t.description||"",status:t.status||"draft",level:t.level||"",instructor_id:t.instructor_id||"",exam_category_id:t.exam_category_id||""}),y=s=>{s.preventDefault(),C(route("exams.update",{exam:t.id}))},E=B.useMemo(()=>l.map(s=>({label:s.title,value:s.id.toString()})),[l]),I=c==null?void 0:c.map(s=>({label:s.user.name,value:s.id.toString()})),N=["beginner","intermediate","advanced"],D=["draft","published","archived"],d=l.find(s=>s.id===a.exam_category_id);return e.jsx(M,{className:"container p-4 sm:p-6",children:e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Exam Title *"}),e.jsx(k,{name:"title",value:a.title,onChange:s=>g(s,r),placeholder:"Enter exam title"}),e.jsx(o,{message:i.title})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Short Description"}),e.jsx(z,{rows:5,name:"short_description",value:a.short_description,onChange:s=>g(s,r),placeholder:"Brief description for exam cards"}),e.jsx(o,{message:i.short_description})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Description"}),e.jsx(w,{ssr:!0,output:"html",placeholder:{paragraph:"Enter detailed exam description...",imageCaption:"Enter detailed exam description..."},contentMinHeight:256,contentMaxHeight:640,initialContent:a.description,onContentChange:s=>r(L=>({...L,description:s}))}),e.jsx(o,{message:i.description})]}),f.user.role==="admin"&&S.sub_type==="collaborative"&&e.jsxs("div",{children:[e.jsx(n,{children:"Exam Instructor *"}),e.jsx(m,{defaultValue:a.instructor_id.toString(),data:I||[],placeholder:"Select instructor",onSelect:s=>r("instructor_id",s.value)}),e.jsx(o,{message:i.instructor_id})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Category *"}),e.jsx(m,{data:E,placeholder:"Select category",defaultValue:(d==null?void 0:d.id.toString())||"",onSelect:s=>{r("exam_category_id",s.value)}}),e.jsx(o,{message:i.exam_category_id})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Difficulty Level *"}),e.jsxs(p,{value:a.level,onValueChange:s=>r("level",s),children:[e.jsx(x,{children:e.jsx(h,{placeholder:"Select level"})}),e.jsx(u,{children:N.map(s=>e.jsx(j,{value:s,className:"capitalize",children:s},s))})]}),e.jsx(o,{message:i.level})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Status *"}),e.jsxs(p,{value:a.status,onValueChange:s=>r("status",s),children:[e.jsx(x,{children:e.jsx(h,{placeholder:"Select status"})}),e.jsx(u,{children:D.map(s=>e.jsx(j,{value:s,className:"capitalize",children:s},s))})]}),e.jsx(o,{message:i.status})]})]}),e.jsx("div",{className:"mt-8",children:e.jsx(H,{loading:b,children:"Save Changes"})})]})})};export{$ as default};
|