"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[87901],{87901:(e,t,s)=>{s.r(t),s.d(t,{default:()=>o});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 o(){let[e,t]=(0,l.useState)([]),[s,o]=(0,l.useState)(""),[h,x]=(0,l.useState)(""),[u,j]=(0,l.useState)(""),[f,N]=(0,l.useState)(null),[p,b]=(0,l.useState)(!1);(0,l.useEffect)(()=>{(0,i.dx)().then(t).catch(e=>{t([]),(0,m.Qg)(e instanceof Error?e.message:"Failed to load classes")})},[]);let C=(0,l.useCallback)(async()=>{if(s){b(!0);try{N(await (0,i.Wh)({schoolClassId:s,from:h||void 0,to:u||void 0}))}catch(e){(0,m.Qg)(e instanceof Error?e.message:"Failed to load report"),N(null)}finally{b(!1)}}},[s,h,u]);return(0,a.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,a.jsx)(n.wc,{title:"Attendance report",description:"Present, absent, and late counts per student — printable for the office."}),(0,a.jsx)(c.f,{}),(0,a.jsxs)(r.r7,{children:[(0,a.jsx)(r.yB,{label:"Class",className:"min-w-0 flex-1 sm:min-w-[12rem]",children:(0,a.jsxs)(r.Kd,{value:s,onChange:e=>o(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.yB,{label:"From",className:"min-w-0 flex-1 sm:min-w-[10rem]",children:(0,a.jsx)(r.IM,{value:h,onChange:e=>x(e.target.value)})}),(0,a.jsx)(r.yB,{label:"To",className:"min-w-0 flex-1 sm:min-w-[10rem]",children:(0,a.jsx)(r.IM,{value:u,onChange:e=>j(e.target.value)})}),(0,a.jsx)(r.bE,{children:(0,a.jsx)(r.kL,{type:"button",onClick:()=>void C(),disabled:!s||p,children:p?"Loading…":"Generate"})})]}),f?(0,a.jsx)(d.J,{title:"Attendance report",subtitle:f.schoolClass.displayName,meta:`${f.totalSessions} session(s)${h||u?` \xb7 ${h||"…"} to ${u||"…"}`:""}`,children:(0,a.jsx)(r.T7,{children:(0,a.jsxs)(r.cR,{minWidth:"36rem",children:[(0,a.jsx)(r.K_,{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:`${r.aB} font-medium`,children:"Student"}),(0,a.jsx)("th",{className:`${r.aB} font-medium`,children:"Roll"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"Present"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"Late"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"Absent"}),(0,a.jsx)("th",{className:`${r.aB} font-medium text-center`,children:"%"})]})}),(0,a.jsx)("tbody",{children:0===f.students.length?(0,a.jsx)(r.tU,{colSpan:6,children:"No attendance data for this range."}):f.students.map(e=>(0,a.jsxs)("tr",{className:"border-t border-slate-100",children:[(0,a.jsx)("td",{className:`${r.Cl} font-medium text-slate-900`,children:e.fullName}),(0,a.jsx)("td",{className:r.Cl,children:e.rollNumber||"—"}),(0,a.jsx)("td",{className:`${r.Cl} text-center`,children:e.present}),(0,a.jsx)("td",{className:`${r.Cl} text-center`,children:e.late}),(0,a.jsx)("td",{className:`${r.Cl} text-center`,children:e.absent}),(0,a.jsxs)("td",{className:`${r.Cl} text-center font-medium`,children:[e.attendancePercent??"—","%"]})]},e.userId))})]})})}):null]})}}}]);