1import{r,j as e}from"./react-vendor-DDlTsOEd.js";import{ae as T,k as v,K as o,v as z,U as A,a3 as M,d as g,ad as x,G as f,J as N}from"./index-BBAL-XO_.js";import{A as $}from"./AdminLayout-B0DIBAYd.js";import{B as D}from"./badge-D-Efy8A-.js";import{T as P}from"./textarea-H_45bX76.js";import{D as E,a as L,b as R,c as B,d as I}from"./dialog-BMs1NjFS.js";import{S as F}from"./skeleton-DBoY5sj-.js";import{C as w}from"./chevron-right-BXLWPEsY.js";import{P as k}from"./plus-CPYb50Rr.js";import{P as G}from"./pen-RUwe4MY3.js";import{T as U}from"./trash-2-Drz6h9-N.js";import"./megaphone-c2Ccoqv-.js";import"./clipboard-check-B-VFQxDc.js";import"./database-CfQ3DoFp.js";import"./tag-finmna5A.js";import"./credit-card-jC5ykv7d.js";import"./index-xaFI6AS-.js";function q({open:c,onClose:i,courseId:u,editAssignment:a,onSave:h}){const[d,p]=r.useState(""),[j,m]=r.useState(""),[n,l]=r.useState(100),[b,s]=r.useState(""),[y,C]=r.useState(!1);r.useEffect(()=>{c&&(p(a?.title??""),m(a?.description??""),l(a?.totalMarks??100),s(a?.dueDate?a.dueDate.split("T")[0]:""))},[c,a]);async function S(){if(!d.trim()){x({title:"Title required",variant:"destructive"});return}C(!0);try{const t={title:d,description:j,totalMarks:n,dueDate:b||null};a?(await g.put(`/admin/assignments/${a.id}`,t),x({title:"Assignment updated"})):(await g.post(`/admin/courses/${u}/assignments`,t),x({title:"Assignment created"})),h(),i()}catch{x({title:"Save failed",variant:"destructive"})}finally{C(!1)}}return e.jsx(E,{open:c,onOpenChange:t=>!t&&i(),children:e.jsxs(L,{className:"max-w-lg bg-white border-gray-200 text-gray-900",children:[e.jsx(R,{children:e.jsx(B,{className:"text-gray-900",children:a?"Edit Assignment":"Create Assignment"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(f,{className:"text-gray-900",children:"Title *"}),e.jsx(N,{value:d,onChange:t=>p(t.target.value),placeholder:"e.g. Mid-Term Astrology Evaluation",className:"bg-white border-gray-300 text-gray-900 mt-1"})]}),e.jsxs("div",{children:[e.jsx(f,{className:"text-gray-900",children:"Instructions / Description"}),e.jsx(P,{value:j,onChange:t=>m(t.target.value),placeholder:"Describe what students need to submit...",className:"bg-white border-gray-300 text-gray-900 mt-1 min-h-[100px]"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(f,{className:"text-gray-900",children:"Total Marks"}),e.jsx(N,{type:"number",min:1,max:1e3,value:n,onChange:t=>l(Number(t.target.value)),className:"bg-white border-gray-300 text-gray-900 mt-1"})]}),e.jsxs("div",{children:[e.jsxs(f,{className:"text-gray-900",children:["Due Date ",e.jsx("span",{className:"text-gray-900",children:"(optional)"})]}),e.jsx(N,{type:"date",value:b,onChange:t=>s(t.target.value),className:"bg-white border-gray-300 text-gray-900 mt-1"})]})]})]}),e.jsxs(I,{children:[e.jsx(o,{variant:"outline",onClick:i,className:"border-gray-300 text-gray-900",children:"Cancel"}),e.jsx(o,{onClick:S,disabled:y,className:"bg-blue-600 hover:bg-blue-500",children:y?"Saving...":a?"Save Changes":"Create"})]})]})})}function ne(){const{id:c}=T(),i=Number(c),[u,a]=r.useState(null),[h,d]=r.useState([]),[p,j]=r.useState(!0),[m,n]=r.useState({open:!1});async function l(){try{const[s,y]=await Promise.all([g.get(`/courses/${i}`),g.get(`/admin/courses/${i}/assignments`)]);a(s.data??null),d(y.data??[])}finally{j(!1)}}r.useEffect(()=>{l()},[i]);async function b(s){confirm("Delete this assignment and all submissions?")&&(await g.delete(`/admin/assignments/${s}`),x({title:"Assignment deleted"}),l())}return e.jsxs($,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-900 mb-4",children:[e.jsx(v,{href:"/admin/courses",children:e.jsx("span",{className:"hover:text-blue-600 cursor-pointer text-gray-900",children:"Courses"})}),e.jsx(w,{size:14}),e.jsx(v,{href:`/admin/courses/${i}/builder`,children:e.jsx("span",{className:"hover:text-blue-600 cursor-pointer text-gray-900",children:u?.title??"..."})}),e.jsx(w,{size:14}),e.jsx("span",{className:"text-gray-900",children:"Assignments"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Assignments"}),e.jsx("p",{className:"text-gray-900 text-sm mt-1",children:u?.title})]}),e.jsxs(o,{onClick:()=>n({open:!0}),className:"bg-blue-600 hover:bg-blue-500 gap-2",children:[e.jsx(k,{size:16})," Create Assignment"]})]}),p?e.jsx("div",{className:"space-y-3",children:[1,2].map(s=>e.jsx(F,{className:"h-24 bg-gray-100 rounded-xl"},s))}):h.length===0?e.jsx("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm",children:e.jsxs("div",{className:"py-16 text-center",children:[e.jsx(z,{size:40,className:"text-gray-900 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-900 mb-4",children:"No assignments yet. Create your first one."}),e.jsxs(o,{onClick:()=>n({open:!0}),className:"bg-blue-600 hover:bg-blue-500 gap-2",children:[e.jsx(k,{size:16})," Create Assignment"]})]})}):e.jsx("div",{className:"space-y-3",children:h.map(s=>e.jsx("div",{className:"bg-white border border-gray-200 rounded-xl shadow-sm hover:shadow-md transition-shadow",children:e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h3",{className:"text-gray-900 font-semibold",children:s.title}),e.jsxs(D,{className:"bg-amber-50 text-amber-700 border-amber-200 font-mono",children:[s.totalMarks," marks"]}),s.dueDate&&e.jsxs(D,{className:"bg-gray-100 text-gray-800 border-gray-200 text-xs",children:["Due ",new Date(s.dueDate).toLocaleDateString()]})]}),s.description&&e.jsx("p",{className:"text-gray-900 text-sm line-clamp-2",children:s.description})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(v,{href:`/admin/assignments/${s.id}/grade`,children:e.jsxs(o,{size:"sm",variant:"outline",className:"border-blue-200 text-blue-700 hover:bg-blue-50 gap-1.5 text-xs",children:[e.jsx(A,{size:13})," Grade"]})}),e.jsx(v,{href:`/admin/assignments/${s.id}/grade?tab=rankings`,children:e.jsxs(o,{size:"sm",variant:"outline",className:"border-emerald-200 text-emerald-700 hover:bg-emerald-50 gap-1.5 text-xs",children:[e.jsx(M,{size:13})," Rankings"]})}),e.jsx("button",{onClick:()=>n({open:!0,edit:s}),className:"p-1.5 text-gray-900 hover:text-blue-600 transition-colors",children:e.jsx(G,{size:15})}),e.jsx("button",{onClick:()=>b(s.id),className:"p-1.5 text-gray-900 hover:text-red-500 transition-colors",children:e.jsx(U,{size:15})})]})]})})},s.id))}),e.jsx(q,{open:m.open,onClose:()=>n({open:!1}),courseId:i,editAssignment:m.edit,onSave:l})]})}
1export{ne as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.