"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[80941],{80941:(e,t,a)=>{a.r(t),a.d(t,{default:()=>o});var s=a(95155),l=a(12115),r=a(30571),n=a(30313),d=a(75560),i=a(2581);let c={PRESENT:"bg-emerald-50 text-emerald-800",ABSENT:"bg-rose-50 text-rose-800",LATE:"bg-amber-50 text-amber-800"};function o(){let[e,t]=(0,l.useState)(null),[a,o]=(0,l.useState)(!0),[m,x]=(0,l.useState)(()=>{let e=new Date;return e.setUTCDate(e.getUTCDate()-60),e.toISOString().slice(0,10)}),[u,h]=(0,l.useState)(()=>new Date().toISOString().slice(0,10)),b=(0,l.useMemo)(()=>async()=>{o(!0);try{t(await (0,d.Hj)({from:m,to:u}))}catch(e){(0,i.Qg)(e instanceof Error?e.message:"Failed to load attendance"),t(null)}finally{o(!1)}},[m,u]);(0,l.useEffect)(()=>{b()},[b]);let p=e?.summary;return(0,s.jsxs)(r.o,{title:"Attendance",description:e?.profile.schoolClass?.displayName?`Present, absent, and late days for ${e.profile.schoolClass.displayName}.`:"Your present, absent, and late days.",children:[(0,s.jsx)("div",{className:"rounded-lg border border-slate-100 bg-white p-4 shadow-sm",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,s.jsxs)("label",{className:"text-sm",children:[(0,s.jsx)("span",{className:"mb-1 block text-slate-500",children:"From"}),(0,s.jsx)("input",{type:"date",value:m,onChange:e=>x(e.target.value),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900"})]}),(0,s.jsxs)("label",{className:"text-sm",children:[(0,s.jsx)("span",{className:"mb-1 block text-slate-500",children:"To"}),(0,s.jsx)("input",{type:"date",value:u,onChange:e=>h(e.target.value),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900"})]})]})}),a?(0,s.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-slate-100"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.jQ,{items:[{label:"Present",value:p?.present??0},{label:"Absent",value:p?.absent??0},{label:"Late",value:p?.late??0},{label:"Present rate",value:`${p?.presentRate??0}%`}]}),(0,s.jsx)("div",{className:"overflow-hidden rounded-lg border border-slate-100 bg-white shadow-sm",children:e?.days.length?(0,s.jsx)("ul",{className:"divide-y divide-slate-100",children:e.days.map(e=>(0,s.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-3 text-sm sm:px-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-slate-900",children:new Date(`${e.date}T12:00:00`).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric"})}),e.notes?(0,s.jsx)("p",{className:"text-xs text-slate-500",children:e.notes}):null]}),(0,s.jsx)("span",{className:`rounded-md px-2 py-0.5 text-xs font-semibold ${c[e.status]||"bg-slate-100 text-slate-700"}`,children:e.status})]},e.date))}):(0,s.jsx)("div",{className:"p-6",children:(0,s.jsx)(n.i0,{title:"No attendance in this range",description:"Try a different date range or check back after your teacher marks attendance."})})})]})]})}}}]);