"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[29305],{29305:(e,t,s)=>{s.r(t),s.d(t,{default:()=>x});var a=s(95155),l=s(12115),n=s(74016),r=s(30313),c=s(95355),d=s(27665),i=s(7404),m=s(2581);function x(){let[e,t]=(0,l.useState)([]),[s,x]=(0,l.useState)([]),[o,u]=(0,l.useState)(""),[h,j]=(0,l.useState)(""),[b,f]=(0,l.useState)(null),[N,p]=(0,l.useState)(!1);(0,l.useEffect)(()=>{Promise.all([(0,i.dx)(),(0,i.jS)()]).then(([e,s])=>{t(e.filter(e=>e.isActive)),x(s.filter(e=>e.isActive))}).catch(e=>{t([]),x([]),(0,m.Qg)(e instanceof Error?e.message:"Failed to load filters")})},[]);let $=(0,l.useCallback)(async()=>{if(h&&o){p(!0);try{f(await (0,i.VT)({examId:h,schoolClassId:o}))}catch(e){(0,m.Qg)(e instanceof Error?e.message:"Failed to load mark sheet"),f(null)}finally{p(!1)}}},[h,o]);return(0,a.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,a.jsx)(n.wc,{title:"Mark sheet",description:"Class \xd7 subject marks matrix with totals, grade, and result. Print or save as PDF."}),(0,a.jsx)(c.f,{}),(0,a.jsxs)(r.r7,{children:[(0,a.jsx)(r.yB,{label:"Exam",className:"min-w-0 flex-1 sm:min-w-[12rem]",children:(0,a.jsxs)(r.Kd,{value:h,onChange:e=>j(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select exam"}),s.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,a.jsx)(r.yB,{label:"Class",className:"min-w-0 flex-1 sm:min-w-[12rem]",children:(0,a.jsxs)(r.Kd,{value:o,onChange:e=>u(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select class"}),e.map(e=>(0,a.jsx)("option",{value:e.id,children:e.displayName},e.id))]})}),(0,a.jsx)(r.bE,{children:(0,a.jsx)(r.kL,{type:"button",onClick:()=>void $(),disabled:!h||!o||N,children:N?"Loading…":"Generate"})})]}),b?(0,a.jsx)(d.J,{letterhead:b.letterhead,title:"Mark sheet",subtitle:`${b.exam.name} \xb7 ${b.schoolClass.displayName}`,meta:b.exam.academicYear?`${b.exam.academicYear.name} \xb7 Generated ${new Date(b.generatedAt).toLocaleString()}`:`Generated ${new Date(b.generatedAt).toLocaleString()}`,children:(0,a.jsx)(r.T7,{children:(0,a.jsxs)(r.cR,{minWidth:"48rem",children:[(0,a.jsx)(r.K_,{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:`${r.aB} font-medium`,children:"Roll"}),(0,a.jsx)("th",{className:`${r.aB} font-medium`,children:"Student"}),b.subjects.map(e=>(0,a.jsxs)("th",{className:`${r.aB} font-medium text-center`,children:[e.name,(0,a.jsxs)("span",{className:"block text-[10px] font-normal text-slate-400",children:["/",e.fullMarks]})]},e.subjectId)),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"Total"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"%"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"Grade"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"Result"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"Rank"})]})}),(0,a.jsx)("tbody",{children:b.students.length?b.students.map(e=>(0,a.jsxs)("tr",{className:"border-t border-slate-100",children:[(0,a.jsx)("td",{className:r.Cl,children:e.rollNumber||"—"}),(0,a.jsx)("td",{className:`${r.Cl} font-medium text-slate-900`,children:e.fullName}),e.subjects.map(e=>(0,a.jsx)("td",{className:`${r.Cl} text-center tabular-nums`,children:e.marksObtained??"—"},e.subjectId)),(0,a.jsx)("td",{className:`${r.Cl} text-center tabular-nums font-semibold`,children:e.totals.subjectsCounted?e.totals.obtained:"—"}),(0,a.jsx)("td",{className:`${r.Cl} text-center tabular-nums`,children:e.totals.percent??"—"}),(0,a.jsx)("td",{className:`${r.Cl} text-center`,children:e.totals.overallGrade||"—"}),(0,a.jsx)("td",{className:`${r.Cl} text-center text-xs font-semibold`,children:e.totals.result}),(0,a.jsx)("td",{className:`${r.Cl} text-center tabular-nums`,children:e.rank??"—"})]},e.userId)):(0,a.jsx)(r.tU,{colSpan:6+b.subjects.length,children:"No students"})})]})})}):null]})}}}]);