"use strict";exports.id=52762,exports.ids=[52762],exports.modules={52762:(a,b,c)=>{c.r(b),c.d(b,{default:()=>l});var d=c(48249),e=c(67484),f=c(19099),g=c(63754),h=c(82697),i=c(24403),j=c(91115);let k=[{value:"PENDING",label:"Pending"},{value:"SUBMITTED",label:"Submitted"},{value:"CHECKED",label:"Checked"},{value:"LATE",label:"Late"},{value:"MISSING",label:"Missing"}];function l(){let a=(0,f.useSearchParams)().get("homeworkId")??"",[b,c]=(0,e.useState)([]),[l,m]=(0,e.useState)(a),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(!1),v=(0,e.useCallback)(async()=>{if(!l){o(null),q([]);return}s(!0);try{let a=await (0,i.j)(l);o(a.homework),q(a.students.map(a=>({userId:a.userId,fullName:a.fullName,rollNumber:a.rollNumber,status:a.status,marks:null==a.marks?"":String(a.marks),remarks:a.remarks||""})))}catch(a){(0,j.Qg)(a instanceof Error?a.message:"Failed to load evaluation"),o(null),q([])}finally{s(!1)}},[l]),w=(a,b)=>{q(c=>c.map(c=>c.userId===a?{...c,...b}:c))},x=async a=>{if(a.preventDefault(),l){u(!0);try{await (0,i.kW)(l,{records:p.map(a=>({userId:a.userId,status:a.status,marks:""===a.marks?null:Number(a.marks),remarks:a.remarks.trim()||null}))}),(0,j.Te)("Evaluation saved"),v()}catch(a){(0,j.Qg)(a instanceof Error?a.message:"Failed to save evaluation")}finally{u(!1)}}};return(0,d.jsxs)(g.V,{title:"Homework evaluation",description:"Record status, marks, and remarks for each student.",children:[(0,d.jsx)("div",{className:"rounded-lg border border-slate-100 bg-white p-4 shadow-sm",children:(0,d.jsxs)("label",{className:"block text-sm",children:[(0,d.jsx)("span",{className:"mb-1 block text-slate-500",children:"Homework"}),(0,d.jsxs)("select",{value:l,onChange:a=>m(a.target.value),className:"block w-full min-h-[44px] rounded-md border border-slate-200 px-3 py-2 text-sm",children:[(0,d.jsx)("option",{value:"",children:"Select homework"}),b.map(a=>(0,d.jsxs)("option",{value:a.id,children:[a.title," \xb7 ",a.schoolClass?.displayName||"Class"]},a.id))]})]})}),l?r?(0,d.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-slate-100"}):p.length?(0,d.jsxs)("form",{onSubmit:x,className:"space-y-4",children:[n?(0,d.jsxs)("p",{className:"text-sm text-slate-600",children:[(0,d.jsx)("span",{className:"font-medium text-slate-900",children:n.title}),null!=n.maxMarks?` \xb7 Max ${n.maxMarks}`:""]}):null,(0,d.jsx)("div",{className:"overflow-hidden rounded-lg border border-slate-100 bg-white shadow-sm",children:(0,d.jsx)("ul",{className:"divide-y divide-slate-100",children:p.map(a=>(0,d.jsxs)("li",{className:"space-y-3 px-4 py-4 sm:px-5",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium text-slate-900",children:a.fullName}),a.rollNumber?(0,d.jsxs)("p",{className:"text-xs text-slate-500",children:["Roll ",a.rollNumber]}):null]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,d.jsx)("select",{value:a.status,onChange:b=>w(a.userId,{status:b.target.value}),className:"rounded-md border border-slate-200 px-2 py-2 text-sm",children:k.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))}),(0,d.jsx)("input",{type:"number",min:0,placeholder:"Marks",value:a.marks,onChange:b=>w(a.userId,{marks:b.target.value}),className:h.Mg}),(0,d.jsx)("input",{type:"text",placeholder:"Remarks",value:a.remarks,onChange:b=>w(a.userId,{remarks:b.target.value}),className:h.Mg})]})]},a.userId))})}),(0,d.jsx)(h.bE,{children:(0,d.jsx)(h.kL,{type:"submit",isLoading:t,children:"Save evaluation"})})]}):(0,d.jsx)(h.i0,{title:"No students",description:"No enrolled students for this homework."}):(0,d.jsx)(h.i0,{title:"Select homework",description:"Choose a homework assignment to evaluate."})]})}}};