1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as i}from"./vendor-react-zNM0AU50.js";import{x as O}from"./index-D1K3lVhu.js";import{D as f}from"./DepartmentSelectorBar-EFx-1H4v.js";import{e as u}from"./educationService-BxXX95Q0.js";import{J as j,c as v,ae as z,z as h}from"./vendor-ui-CW5bJ11U.js";import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";function Q(){const{selectedDepartment:o,isAllSelected:N}=O(),[l,w]=i.useState("check"),[c,S]=i.useState([]),[m,k]=i.useState([]),[C,p]=i.useState(!0),[b,E]=i.useState(()=>new Date().toISOString().split("T")[0]),[y,M]=i.useState("주ì¼ìë°°"),[x,g]=i.useState({}),[A,G]=i.useState({});i.useEffect(()=>{o&&I()},[o]);const I=async()=>{if(o){p(!0);try{const[t,n]=await Promise.all([u.getStudents(o.firestorePrefix),u.getGroups(o.firestorePrefix)]);S(t.filter(s=>s.status==="íë")),k(n);const r={};t.forEach(s=>{s.status==="íë"&&(r[s.id]="ì¶ì")}),g(r)}catch(t){console.error("ë°ì´í° ë¡ë© ì¤í¨:",t)}finally{p(!1)}}},D=async()=>{if(!o){h.error("ë¶ì를 ì íí´ì£¼ì¸ì");return}const t=c.map(a=>({studentId:a.id,studentName:a.name,groupId:a.groupId,groupName:a.groupName,status:x[a.id]||"ì¶ì",memo:A[a.id]||""})),n=t.filter(a=>a.status==="ì¶ì").length,r=t.filter(a=>a.status==="ê²°ì").length,s=t.filter(a=>a.status==="ì§ê°").length,d=t.filter(a=>a.status==="ì¬ì ê²°ì").length;try{await u.createAttendance(o.firestorePrefix,{date:b,type:y,records:t,totalPresent:n,totalAbsent:r,totalLate:s,totalExcused:d}),h.success(`ì¶ìì´ ì ì¥ëììµëë¤ (ì¶ì ${n} / ê²°ì ${r})`)}catch{h.error("ì¶ì ì ì¥ì ì¤í¨íìµëë¤")}},P=m.length>0?m.map(t=>({group:t,students:c.filter(n=>n.groupId===t.id)})).concat([{group:{id:"",name:"미배ì ",sortOrder:999},students:c.filter(t=>!t.groupId||!m.find(n=>n.id===t.groupId))}]).filter(t=>t.students.length>0):[{group:{id:"",name:"ì ì²´",sortOrder:0},students:c}],T=[{id:"check",label:"ì¶ìì²´í¬"},{id:"history",label:"ì¶ì기ë¡"},{id:"stats",label:"ì¶ìíµê³"}];return N?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"ì¶ê²° ê´ë¦¬"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"ë¶ì를 ì ííë©´ ì¶ìì²´í¬ë¥¼ ììí ì ììµëë¤"})]}),e.jsx(f,{}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-12 text-center text-gray-400",children:[e.jsx(j,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"ì¶ìì²´í¬ë¥¼ ìí´ ë¶ì를 ì íí´ì£¼ì¸ì"})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"ì¶ê²° ê´ë¦¬"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:o==null?void 0:o.name})]}),e.jsx(f,{}),e.jsx("div",{className:"flex gap-1 bg-gray-100 p-1 rounded-lg w-fit",children:T.map(t=>e.jsx("button",{onClick:()=>w(t.id),className:`px-4 py-2 text-sm font-medium rounded-md transition-colors ${l===t.id?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:t.label},t.id))}),l==="check"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 bg-white rounded-xl border border-gray-200 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-gray-400"}),e.jsx("input",{type:"date",value:b,onChange:t=>E(t.target.value),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20"})]}),e.jsxs("select",{value:y,onChange:t=>M(t.target.value),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20",children:[e.jsx("option",{value:"주ì¼ìë°°",children:"주ì¼ìë°°"}),e.jsx("option",{value:"ìììë°°",children:"ìììë°°"}),e.jsx("option",{value:"ê¸ììë°°",children:"ê¸ììë°°"}),e.jsx("option",{value:"í¹ë³ìë°°",children:"í¹ë³ìë°°"})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs("button",{onClick:D,className:"flex items-center gap-2 px-5 py-2.5 bg-blue-600 text-white rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors",children:[e.jsx(z,{className:"w-4 h-4"}),"ì ì¥"]})})]}),C?e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-12 text-center text-gray-400",children:[e.jsx("div",{className:"inline-block w-8 h-8 border-2 border-gray-200 border-t-blue-500 rounded-full animate-spin mb
1-3"}),e.jsx("p",{children:"íì 목ë¡ì ë¶ë¬ì¤ë ì¤..."})]}):P.map(({group:t,students:n})=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-gray-50 border-b border-gray-200",children:[e.jsxs("span",{className:"font-medium text-gray-900",children:[t.name," (",n.length,"ëª
)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const r={...x};n.forEach(s=>{r[s.id]="ì¶ì"}),g(r)},className:"px-2 py-1 text-xs bg-green-100 text-green-700 rounded hover:bg-green-200",children:"ì ì²´ì¶ì"}),e.jsx("button",{onClick:()=>{const r={...x};n.forEach(s=>{r[s.id]="ê²°ì"}),g(r)},className:"px-2 py-1 text-xs bg-red-100 text-red-700 rounded hover:bg-red-200",children:"ì ì²´ê²°ì"})]})]}),e.jsx("div",{className:"divide-y divide-gray-100",children:n.map(r=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("span",{className:"w-20 font-medium text-gray-900 truncate",children:r.name}),e.jsx("span",{className:"w-12 text-xs text-gray-400",children:r.grade||""}),e.jsx("div",{className:"flex gap-1 ml-auto",children:["ì¶ì","ê²°ì","ì§ê°","ì¬ì ê²°ì"].map(s=>{const d=(x[r.id]||"ì¶ì")===s,a={ì¶ì:d?"bg-green-500 text-white":"bg-gray-100 text-gray-500 hover:bg-green-100",ê²°ì:d?"bg-red-500 text-white":"bg-gray-100 text-gray-500 hover:bg-red-100",ì§ê°:d?"bg-yellow-500 text-white":"bg-gray-100 text-gray-500 hover:bg-yellow-100",ì¬ì ê²°ì:d?"bg-blue-500 text-white":"bg-gray-100 text-gray-500 hover:bg-blue-100"};return e.jsx("button",{onClick:()=>g($=>({...$,[r.id]:s})),className:`px-2.5 py-1.5 text-xs rounded-lg font-medium transition-colors ${a[s]}`,children:s==="ì¬ì ê²°ì"?"ì¬ì ":s},s)})})]},r.id))})]},t.id||"unassigned"))]}),l==="history"&&e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-12 text-center text-gray-400",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"ì¶ì ê¸°ë¡ íì´ì§ (구í ìì )"})]}),l==="stats"&&e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-12 text-center text-gray-400",children:[e.jsx(j,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"ì¶ì íµê³ íì´ì§ (구í ìì )"})]})]})}export{Q as AttendanceManagementPage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.