1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as l,L as h}from"./vendor-react-zNM0AU50.js";import{u as U,m as F,L as $,C as v,W as H,S as m,q as i,r as c,t as d,B as N,v as O,w as Q}from"./index-D1K3lVhu.js";import{a as n}from"./attendanceService-CvkHMi2v.js";import{P as z,a as I}from"./PageHeader-vb1XdvVj.js";import{ai as J,bw as V,bx as X,a5 as w,by as Y,e as M,c as Z,i as ee,U as C,s as se,S as te,a as g}from"./vendor-ui-CW5bJ11U.js";import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";function me(){const{user:ae}=U(),[S,b]=l.useState(!0),[s,u]=l.useState(null),[j,L]=l.useState([]),[B,k]=l.useState([]),[T,W]=l.useState([]),[P,D]=l.useState([]),[y,A]=l.useState(0);l.useEffect(()=>{q()},[]);const q=async()=>{try{b(!0);let t=[];try{t=await F.getMembers()}catch(o){console.error("êµì¸ ë°ì´í° ë¡ë ì¤í¨:",o)}try{const o=await n.getDashboardStats();u(o)}catch(o){console.error("ëìë³´ë íµê³ ë¡ë ì¤í¨:",o),u({today:0,thisWeek:0,thisMonth:0,lastMonth:0,byMethod:{geofence:0,geofence_bg:0,qr:0,manual:0,admin:0},avgWeekly:0})}const r=await Promise.allSettled([n.getAttendanceByServiceType(30),n.getWeeklyTrend(8),n.getMonthlyTrend(12),n.getAttendanceByParish(30,t),n.getAbsentMembers(2,t)]);r[0].status==="fulfilled"&&L(r[0].value),r[1].status==="fulfilled"&&k(r[1].value),r[2].status==="fulfilled"&&W(r[2].value),r[3].status==="fulfilled"&&D(r[3].value),r[4].status==="fulfilled"&&A(r[4].value.length)}catch(t){console.error("ëìë³´ë ë°ì´í° ë¡ë ì¤í¨:",t)}finally{b(!1)}};if(S)return e.jsx($,{});const x=s&&s.lastMonth>0?Math.round((s.thisMonth-s.lastMonth)/s.lastMonth*100):0,G=(j||[]).map((t,r)=>({name:t.serviceType,value:t.count,color:v[r%v.length]})),R=(B||[]).map(t=>({name:t.weekLabel,ì¶ìì:t.count,ì°¸ìì¸ì:t.uniqueMembers})),_=(T||[]).map(t=>({name:t.monthLabel,ì¶ìì:t.count,주ì¼íê· :t.avgPerSunday})),f=(P||[]).filter(t=>t.parish!=="미ì§ì ").map(t=>({name:t.parish,ì¶ìë¥ :t.attendanceRate,ì¶ìì¸ì:t.attendedMembers,ì ì²´ì¸ì:t.totalMembers})),a=s?s.byMethod.geofence+s.byMethod.geofence_bg+s.byMethod.qr+s.byMethod.manual+s.byMethod.admin:0,p=s?s.byMethod.geofence+s.byMethod.geofence_bg:0,E=a>0?Math.round(p/a*100):0,K=s?[{name:"GPS ìë",value:s.byMethod.geofence,percentage:a>0?Math.round(s.byMethod.geofence/a*100):0,icon:J,color:"text-blue-600",bgColor:"bg-white border border-gray-200"},{name:"백그ë¼ì´ë",value:s.byMethod.geofence_bg,percentage:a>0?Math.round(s.byMethod.geofence_bg/a*100):0,icon:V,color:"text-blue-600",bgColor:"bg-white border border-gray-200"},{name:"QR ì¤ìº",value:s.byMethod.qr,percentage:a>0?Math.round(s.byMethod.qr/a*100):0,icon:X,color:"text-blue-600",bgColor:"bg-white border border-gray-200"},{name:"ìë ì
ë ¥",value:s.byMethod.manual,percentage:a>0?Math.round(s.byMethod.manual/a*100):0,icon:w,color:"text-blue-600",bgColor:"bg-white border border-gray-200"},{name:"ê´ë¦¬ì",value:s.byMethod.admin,percentage:a>0?Math.round(s.byMethod.admin/a*100):0,icon:Y,color:"text-blue-600",bgColor:"bg-white border border-gray-200"}]:[];return e.jsxs(z,{children:[e.jsx(I,{title:"ì¶ì íµê³",description:"êµí ì¶ì íí©ì íëì íì¸íì¸ì",actions:e.jsxs(h,{to:"/attendance/absentees",className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-amber-700 bg-amber-50 rounded-lg hover:bg-amber-100 transition-colors",children:[e.jsx(M,{className:"w-4 h-4"}),"ê²°ìì ê´ë¦¬ (",y,"ëª
)"]})}
1),e.jsxs(H,{columns:4,className:"mb-6",children:[e.jsx(m,{title:"ì¤ë ì¶ì",value:(s==null?void 0:s.today)||0,suffix:"ëª
",icon:e.jsx(Z,{className:"w-5 h-5"}),iconColor:"text-blue-500",iconBgColor:"bg-blue-50"}),e.jsx(m,{title:"ì´ë² 주",value:(s==null?void 0:s.thisWeek)||0,suffix:"ëª
",icon:e.jsx(ee,{className:"w-5 h-5"}),iconColor:"text-blue-500",iconBgColor:"bg-blue-50",footer:`ì£¼ê° íê· : ${(s==null?void 0:s.avgWeekly)||0}ëª
`}),e.jsx(m,{title:"ì´ë² ë¬",value:(s==null?void 0:s.thisMonth)||0,suffix:"ëª
",icon:e.jsx(C,{className:"w-5 h-5"}),iconColor:"text-blue-500",iconBgColor:"bg-blue-50",change:x!==0?{value:x,type:x>0?"increase":"decrease"}:void 0}),e.jsx(m,{title:"ì§ë ë¬",value:(s==null?void 0:s.lastMonth)||0,suffix:"ëª
",icon:e.jsx(se,{className:"w-5 h-5"}),iconColor:"text-gray-500",iconBgColor:"bg-gray-50"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[e.jsxs(i,{children:[e.jsx(c,{title:"ìë³ ì¶ì ì¶ì´",description:"ìµê·¼ 12ê°ì ì¶ì íí©"}),e.jsx(d,{children:e.jsx("div",{className:"h-72",children:e.jsx(N,{data:_,bars:[{dataKey:"ì¶ìì",name:"ì¶ìì",color:"#3B82F6"}],showGrid:!0,showLegend:!1})})})]}),e.jsxs(i,{children:[e.jsx(c,{title:"ìë°°ë³ ì¶ì ë¶í¬",description:"ìµê·¼ 30ì¼ ê¸°ì¤"}),e.jsx(d,{children:e.jsx("div",{className:"h-72 flex items-center justify-center",children:(j||[]).length>0?e.jsx(O,{data:G,showLegend:!0}):e.jsx("p",{className:"text-gray-500",children:"ë°ì´í°ê° ììµëë¤"})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[e.jsxs(i,{children:[e.jsx(c,{title:"ì£¼ê° ì¶ì ì¶ì´",description:"ìµê·¼ 8주 íí©"}),e.jsx(d,{children:e.jsx("div",{className:"h-64",children:e.jsx(Q,{data:R,lines:[{dataKey:"ì¶ìì",name:"ì¶ìì",color:"#3B82F6"},{dataKey:"ì°¸ìì¸ì",name:"ì°¸ìì¸ì",color:"#10B981"}],showGrid:!0,showLegend:!0})})})]}),e.jsxs(i,{children:[e.jsx(c,{title:"êµêµ¬ë³ ì¶ì íí©",description:"ìµê·¼ 30ì¼ ì¶ìë¥ "}),e.jsx(d,{children:e.jsx("div",{className:"h-64",children:f.length>0?e.jsx(N,{data:f,bars:[{dataKey:"ì¶ìë¥ ",name:"ì¶ìë¥ ",color:"#8B5CF6"}],showGrid:!0,showLegend:!1,layout:"vertical"}):e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"êµêµ¬ ë°ì´í°ê° ììµëë¤"})})})]})]}),e.jsxs(i,{className:"mb-6",children:[e.jsx(c,{title:"ì¶ì ë°©ë²ë³ íµê³",description:"ì ì²´ ì¶ì ê¸°ë¡ ê¸°ì¤"}),e.jsxs(d,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:K.map(t=>e.jsxs("div",{className:`${t.bgColor} rounded-xl p-4 flex items-center gap-4`,children:[e.jsx("div",{className:`${t.color} p-3 bg-blue-50 rounded-lg`,children:e.jsx(t.icon,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-gray-600",children:t.name}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900",children:[t.value.toLocaleString(),e.jsxs("span",{className:"text-sm font-normal text-gray-500 ml-1",children:["(",t.percentage,"%)"]})]})]})]},t.name))}),e.jsx("div",{className:"mt-4 p-4 bg-blue-50 rounded-xl border border-blue-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white rounded-lg shadow-sm",children:e.jsx(te,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-700",children:"ìëì¶ì ë¹ì¨"}),e.jsx("p",{className:"text-xs text-gray-500",children:"GPS ìë + 백그ë¼ì´ë / ì ì²´"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-3xl font-bold text-blue-700 tabular-nums",children:[E,"%"]}),e.jsxs("p",{className:"text-xs text-gray-500 tabular-nums",children:[p.toLocaleString()," / ",a.toLocaleString()]})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(h,{to:"/attendance",className:"flex items-center justify-between p-4 bg-white rounded-xl border border-gray-200 hover:border-blue-300 hover:shadow-md transition-all",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:e.jsx(w,{className:"w-5 h-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"ì¶ì ê´ë¦¬"}),e.jsx("p",{className:"text-sm text-gray-500",children:"ì¶ì ê¸°ë¡ ì¡°í ë° ê´ë¦¬"})]})]}),e.jsx(g,{className:"w-5 h-5 text-gray-400"})]}),e.jsxs(h,{to:"/attendance/absentees",className:"flex items-center justify-between p-4 bg-white rounded-xl border border-gray-200 hover:border-amber-300 hover:shadow-md transition-all",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-amber-50 rounded-lg",children:e.jsx(M,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"ê²°ìì ê´ë¦¬"}),e.jsxs("p",{className:"text-sm text-gray-500",children:["2주 ì´ì 미ì¶ìì ",y,"ëª
"]})]})]}),e.jsx(g,{className:"w-5 h-5 text-gray-400"})]}),e.jsxs(h,{to:"/members",className:"flex items-center justify-between p-4 bg-white rounded-xl border border-gray-200 hover:border-blue-300 hover:shadow-md transition-all",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:e.jsx(C,{className:"w-5 h-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"êµì¸ ê´ë¦¬"}),e.jsx("p",{className:"text-sm text-gray-500",children:"êµì¸ ì ë³´ ì¡°í"})]})]}),e.jsx(g,{className:"w-5 h-5 text-gray-400"})]})]})]})}export{me as AttendanceDashboard,me as default};
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.