"use strict";exports.id=77288,exports.ids=[77288],exports.modules={77288:(a,b,c)=>{c.r(b),c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(63754),g=c(82697),h=c(24403),i=c(91115);let j=[{value:"PRESENT",label:"Present"},{value:"ABSENT",label:"Absent"},{value:"LATE",label:"Late"}];function k(){let[a,b]=(0,e.useState)([]),[c,k]=(0,e.useState)(""),[l,m]=(0,e.useState)(()=>new Date().toISOString().slice(0,10)),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(!1),t=(0,e.useCallback)(async()=>{if(c&&l){q(!0);try{let a=await (0,h.y0)(c,l);o(a.students.map(a=>({userId:a.userId,fullName:a.fullName,rollNumber:a.rollNumber,status:a.status})))}catch(a){(0,i.Qg)(a instanceof Error?a.message:"Failed to load attendance"),o([])}finally{q(!1)}}},[c,l]),u=async a=>{if(a.preventDefault(),c){s(!0);try{await (0,h.Z_)({schoolClassId:c,date:l,records:n.map(a=>({userId:a.userId,status:a.status}))}),(0,i.Te)("Attendance saved"),t()}catch(a){(0,i.Qg)(a instanceof Error?a.message:"Failed to save attendance")}finally{s(!1)}}};return(0,d.jsx)(f.V,{title:"Attendance",description:"Mark daily attendance for your assigned class.",children:a.length?(0,d.jsxs)("form",{onSubmit:u,className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-slate-100 bg-white p-4 shadow-sm",children:[(0,d.jsxs)("label",{className:"text-sm min-w-[12rem] flex-1",children:[(0,d.jsx)("span",{className:"mb-1 block text-slate-500",children:"Class"}),(0,d.jsx)("select",{value:c,onChange:a=>k(a.target.value),className:"block w-full min-h-[44px] rounded-md border border-slate-200 px-3 py-2 text-sm",children:a.map(a=>(0,d.jsx)("option",{value:a.id,children:a.displayName},a.id))})]}),(0,d.jsxs)("label",{className:"text-sm",children:[(0,d.jsx)("span",{className:"mb-1 block text-slate-500",children:"Date"}),(0,d.jsx)("input",{type:"date",value:l,onChange:a=>m(a.target.value),className:"rounded-md border border-slate-200 px-3 py-2 text-sm"})]})]}),p?(0,d.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-slate-100"}):n.length?(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:n.map(a=>(0,d.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-3 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.jsx)("select",{value:a.status,onChange:b=>{var c,d;return c=a.userId,d=b.target.value,void o(a=>a.map(a=>a.userId===c?{...a,status:d}:a))},className:"rounded-md border border-slate-200 px-2 py-1.5 text-sm",children:j.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))})]},a.userId))})}):(0,d.jsx)(g.i0,{title:"No students",description:"This class has no enrolled students."}),(0,d.jsx)(g.kL,{type:"submit",disabled:r||!n.length,isLoading:r,children:"Save attendance"})]}):(0,d.jsx)(g.i0,{title:"No class assigned",description:"You need to be assigned as class teacher before marking attendance."})})}}};