PageSourceSearch

https://seodoon-church-admin.web.app/assets/SilverUniversityPage-fEaawAGA.js

js seodoon-church-admin.web.app collected 2026-10-03 12:36:18 UTC 65,978 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as n}from"./vendor-react-zNM0AU50.js";import{G as X,K as _e,U as pe,a5 as he,c as Ne,ar as ve,i as re,A as Ee,B as we,g as $e,a4 as le,E as Se,ax as Te,T as Q,aa as xe,af as ue,a7 as v,X as z,L as ge,f as Ie,ag as Me,a as Oe,Z as Pe,b9 as Re,ai as Le}from"./vendor-ui-CW5bJ11U.js";import{y as W,k as R,u as Z,z as J,l as I,q as V,x as q,m as B,w as Fe}from"./vendor-firebase-Da9KY1q_.js";import{d as D,m as Ce,u as Ye}from"./index-D1K3lVhu.js";import{p as ye}from"./pushService-ggivUk2Y.js";import"./vendor-charts-08G1rM8P.js";const ie="seodoon-church",ee=`churches/${ie}/silverClasses`,te=`churches/${ie}/silverStaff`,U=`churches/${ie}/silverEvents`,se=`churches/${ie}/silverNotices`,ae="silverEnrollments";function L(t){const d={};for(const[s,l]of Object.entries(t))l!==void 0&&(d[s]=l);return d}const ne={async getAll(){try{const t=V(I(D,ee),q("sortOrder","asc"));return(await B(t)).docs.map(s=>{var l,o,a,x;return{id:s.id,...s.data(),createdAt:(o=(l=s.data().createdAt)==null?void 0:l.toDate)==null?void 0:o.call(l),updatedAt:(x=(a=s.data().updatedAt)==null?void 0:a.toDate)==null?void 0:x.call(a)}})}catch(t){return console.error("실버대학 반 조회 실패:",t),[]}},async create(t){const d=L(t);return(await J(I(D,ee),{...d,createdAt:new Date,updatedAt:new Date})).id},async update(t,d){const s=L(d);await Z(R(D,ee,t),{...s,updatedAt:new Date})},async remove(t){await W(R(D,ee,t))}},de={async getAll(){try{const t=V(I(D,te),q("sortOrder","asc"));return(await B(t)).docs.map(s=>{var l,o,a,x;return{id:s.id,...s.data(),createdAt:(o=(l=s.data().createdAt)==null?void 0:l.toDate)==null?void 0:o.call(l),updatedAt:(x=(a=s.data().updatedAt)==null?void 0:a.toDate)==null?void 0:x.call(a)}})}catch(t){return console.error("실버대학 봉사자 조회 실패:",t),[]}},async create(t){const d=L(t);return(await J(I(D,te),{...d,createdAt:new Date,updatedAt:new Date})).id},async update(t,d){const s=L(d);await Z(R(D,te,t),{...s,updatedAt:new Date})},async remove(t){await W(R(D,te,t))}},K={async getAll(){try{const t=V(I(D,U),q("start_date","asc"));return(await B(t)).docs.map(s=>{var l,o,a,x;return{id:s.id,...s.data(),createdAt:(o=(l=s.data().createdAt)==null?void 0:l.toDate)==null?void 0:o.call(l),updatedAt:(x=(a=s.data().updatedAt)==null?void 0:a.toDate)==null?void 0:x.call(a)}})}catch(t){console.error("실버대학 일정 조회 실패:",t);try{const d=V(I(D,U),q("sortOrder","asc"));return(await B(d)).docs.map(l=>{var o,a,x,h;return{id:l.id,...l.data(),createdAt:(a=(o=l.data().createdAt)==null?void 0:o.toDate)==null?void 0:a.call(o),updatedAt:(h=(x=l.data().updatedAt)==null?void 0:x.toDate)==null?void 0:h.call(x)}})}catch{return[]}}},async getByDateRange(t,d){try{const s=V(I(D,U),Fe("start_date","<=",d),q("start_date","asc"));return(await B(s)).docs.map(a=>{var x,h,r,i;return{id:a.id,...a.data(),createdAt:(h=(x=a.data().createdAt)==null?void 0:x.toDate)==null?void 0:h.call(x),updatedAt:(i=(r=a.data().updatedAt)==null?void 0:r.toDate)==null?void 0:i.call(r)}}).filter(a=>a.end_date>=t)}catch(s){return console.error("실버대학 일정 범위 조회 실패:",s),[]}},async create(t){const d=L(t);return d.start_date&&(d.month=parseInt(d.start_date.split("-")[1])),d.sortOrder||(d.sortOrder=0),(await J(I(D,U),{...d,createdAt:new Date,updatedAt:new Date})).id},async update(t,d){const s=L(d);s.start_date&&(s.month=parseInt(s.start_date.split("-")[1])),await Z(R(D,U,t),{...s,updatedAt:new Date})},async remove(t){await W(R(D,U,t))}},ce={async getAll(){try{const t=V(I(D,se),q("createdAt","desc"));return(await B(t)).docs.map(s=>{var l,o,a,x;return{id:s.id,...s.data(),createdAt:(o=(l=s.data().createdAt)==null?void 0:l.toDate)==null?void 0:o.call(l),updatedAt:(x=(a=s.data().updatedAt)==null?void 0:a.toDate)==null?void 0:x.call(a)}})}catch(t){return console.error("실버대학 공지 조회 실패:",t),[]}},async create(t){const d=L(t);return(await J(I(D,se),{...d,createdAt:new Date,updatedAt:new Date})).id},async update(t,d){const s=L(d);await Z(R(D,se,t),{...s,updatedAt:new Date})},async remove(t){await W(R(D,se,t))}},oe={async getAll(){try{const t=V(I(D,ae),q("createdAt","desc"));return(await B(t)).docs.map(s=>{var o,a;const l=s.data();return{id:s.id,...l,createdAt:((a=(o=l.createdAt)==null?void 0:o.toDate)==null?void 0:a.call(o))||l.createdAt}})}catch(t){return console.error("실버대학 수강신청 조회 실패:",t),[]}},async create(t){const d=L(t);return(await J(I(D,ae),{...d,createdAt:new Date})).id},async updateStatus(t,d){await Z(R(D,ae,t),{status:d})},async remove(t){await W(R(D,ae,t))}},be={class:"수업",event:"행사",notice:"공지",other:"기타"},ke=["class","event","notice","other"],H={class:{bg:"bg-amber-50",text:"text-amber-700",border:"border-amber-200",dot:"bg-
1amber-500"},event:{bg:"bg-green-50",text:"text-green-700",border:"border-green-200",dot:"bg-green-500"},notice:{bg:"bg-blue-50",text:"text-blue-700",border:"border-blue-200",dot:"bg-blue-500"},other:{bg:"bg-gray-50",text:"text-gray-600",border:"border-gray-200",dot:"bg-gray-400"}},Ve=["중요","수업안내","행사","일반"],fe={pending:"대기",approved:"승인",rejected:"거절"},qe=["🌼","🌿","🎋","🌸","🌺","🍀","🌻","🌷"],je=["국화반","장미반","백합반","목련반","개나리반","진달래반","무궁화반","해바라기반","튤립반","라일락반","수선화반","매화반","벚꽃반","코스모스반","동백반"];function De({onSelect:t,placeholder:d="교적부에서 검색..."}){const[s,l]=n.useState(!1),[o,a]=n.useState(""),[x,h]=n.useState([]),[r,i]=n.useState([]),[u,y]=n.useState(!1),p=n.useRef(null);return n.useEffect(()=>{(async()=>{y(!0);try{const c=await Ce.getMembers();h(c)}catch{}y(!1)})()},[]),n.useEffect(()=>{if(!o.trim())i(x.slice(0,30));else{const m=o.toLowerCase();i(x.filter(c=>{var f,w;return((f=c.name)==null?void 0:f.toLowerCase().includes(m))||((w=c.phone)==null?void 0:w.includes(m))}).slice(0,30))}},[o,x]),n.useEffect(()=>{const m=c=>{p.current&&!p.current.contains(c.target)&&l(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),e.jsxs("div",{ref:p,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Re,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-amber-500"}),e.jsx("input",{type:"text",value:o,onChange:m=>{a(m.target.value),s||l(!0)},onFocus:()=>l(!0),placeholder:d,className:"w-full pl-8 pr-3 py-2 border border-amber-200 rounded-lg text-[13px] bg-amber-50/50 focus:outline-none focus:ring-2 focus:ring-amber-400"}),u&&e.jsx(ge,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400 animate-spin"})]}),s&&e.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg max-h-52 overflow-y-auto",children:u?e.jsx("div",{className:"p-3 text-center text-gray-400 text-[12px]",children:"로딩 중..."}):r.length===0?e.jsx("div",{className:"p-3 text-center text-gray-400 text-[12px]",children:o?"결과 없음":"교인 없음"}):e.jsx("ul",{children:r.map(m=>{var c;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>{t(m),a(""),l(!1)},className:"w-full px-3 py-2 text-left hover:bg-amber-50 flex items-center gap-2 border-b border-gray-50 last:border-0 text-[12px]",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-gray-100 flex items-center justify-center flex-shrink-0 text-[10px] text-gray-500",children:m.photo_url?e.jsx("img",{src:m.photo_url,alt:"",className:"w-6 h-6 rounded-full object-cover"}):(c=m.name)==null?void 0:c[0]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-gray-900",children:m.name}),e.jsx("span",{className:"text-gray-400 ml-1.5",children:m.position||"성도"})]}),e.jsx("span",{className:"text-gray-400 flex-shrink-0",children:m.mobile_phone||m.phone||""})]})},m.id)})})})]})}function xt(){const[t,d]=n.useState("dashboard"),[s,l]=n.useState([]),[o,a]=n.useState([]),[x,h]=n.useState([]),[r,i]=n.useState([]),[u,y]=n.useState([]),[p,m]=n.useState({}),[c,f]=n.useState(!0),w=n.useCallback(async()=>{f(!0);const[S,b,_,$,E]=await Promise.all([ne.getAll(),de.getAll(),K.getAll(),ce.getAll(),oe.getAll()]);l(S),a(b),h(_),i($),y(E);const g=b.filter(A=>A.memberId).map(A=>A.memberId);if(g.length>0){const A={};await Promise.all(g.map(async T=>{const M=await Ce.getMember(T);M!=null&&M.position&&(A[T]=M.position)})),m(A)}f(!1)},[]);n.useEffect(()=>{w()},[w]);const C=[{id:"dashboard",label:"대시보드",icon:_e},{id:"enrollments",label:"수강신청",icon:pe},{id:"classes",label:"반 편성",icon:X},{id:"staff",label:"봉사자",icon:he},{id:"schedule",label:"일정/공지",icon:Ne}];return e.jsxs("div",{className:"space-y-0",children:[e.jsx("div",{className:"rounded-xl p-6 text-white mb-5",style:{background:"linear-gradient(135deg, #78350f 0%, #92400e 50%, #d97706 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:"w-10 h-10 bg-white/20 rounded-lg flex items-center justify-center",children:e.jsx(X,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-[18px] font-bold",children:"실버대학 관리"}),e.jsx("p",{className:"text-[12px] text-white/70 mt-0.5",children:"반편성, 봉사자, 일정, 공지, 수강신청을 관리합니다"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-lg px-4 py-2 text-center",children:[e.jsx("div",{className:"text-[11px] text-white/70",children:"반"}),e.jsx("div",{className:"text-[22px] font-bold leading-tight",children:s.length})]}),e.jsxs("div",{className:"bg-white/15 backdrop-blur-sm rounded-lg px-4 py-2 text-center",children:[e.jsx("div",{className:"text-[11px] text-white/70",children:"수강신청"}),e.jsx("div",{className:"text-[22px] font-bold leading-tight",children:u.length})]})]})]})}),e.jsx("div",{className:"flex gap-1 border-b border-gray-200 mb-4",children:C.map(S=>e.jsxs("button",{onClick:()=>d(S.id),className:`flex items-center gap-1.5 px-4 py-2.5 text-[13px] font-medium border-b-2 -mb-[1px] transition-colors ${t===S.id?"border-amber-600 text-amber-700":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[e.jsx(S.icon,{className:"w-4 h-4"}),S.label]},S.id))}),c?e.jsx("div",{className:"text-center py-16 text-gray-400 text-[13px]",children:"로딩 중..."}):e.jsxs(e.Fragment,{children:[t==="dashboard"&&e.jsx(Be,{classes:s,staffList:o,enrollments:u,notices:r,events:x}),t==="enrollments"&&e.jsx(ze,{enrollments:u,classes:s,onReload:w}),t==="classes"&&e.jsx(He,{classes:s,staffList:o,onReload:w}),t==="staff"&&e.jsx(Ke,{staffList:o,positionMap:p,onReload:w}),t==="schedule"&&e.jsx(Qe,{events:x,notices:r,onReload:w})]})]})}function Be({classes:t,staffList:d,enrollments:s,notices:l,events:o}){const a=s.filter(r=>r.status==="pending").length,x=s.filter(r=>r.status==="approved").length,h=[{label:"반",value:t.length,unit:"개",color:"#d97706",bg:"#fffbeb",icon:X},{label:"봉사자",value:d.length,unit:"명",color:"#16a34a",bg
1:"#f0fdf4",icon:he},{label:"수강신청",value:s.length,unit:"건",color:"#7c3aed",bg:"#f5f3ff",icon:pe},{label:"승인",value:x,unit:"건",color:"#0891b2",bg:"#ecfeff",icon:ve},{label:"대기",value:a,unit:"건",color:"#ea580c",bg:"#fff7ed",icon:re}];return e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"grid grid-cols-5 gap-3",children:h.map((r,i)=>e.jsxs("div",{className:"rounded-xl p-4 border",style:{backgroundColor:r.bg,borderColor:`${r.color}20`},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[11px] font-medium",style:{color:r.color},children:r.label}),e.jsx(r.icon,{className:"w-4 h-4",style:{color:r.color,opacity:.5}})]}),e.jsxs("div",{className:"text-[24px] font-bold leading-tight",style:{color:r.color},children:[r.value,e.jsx("span",{className:"text-[12px] font-normal ml-0.5",children:r.unit})]})]},i))}),a>0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4 text-amber-500 flex-shrink-0"}),e.jsxs("span",{className:"text-[13px] text-amber-700",children:["확인 대기 중인 수강신청이 ",e.jsxs("strong",{children:[a,"건"]})," 있습니다."]})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-4",children:[e.jsxs("h3",{className:"text-[14px] font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx(X,{className:"w-4 h-4 text-amber-600"}),"반별 현황"]}),t.length===0?e.jsx("div",{className:"text-center py-8 text-gray-400 text-[13px]",children:"등록된 반이 없습니다"}):e.jsx("div",{className:"grid grid-cols-4 gap-3",children:t.map(r=>{const i=s.filter(u=>u.preferredClass===r.name);return e.jsxs("div",{className:"p-3 bg-amber-50/50 rounded-lg border border-amber-100",children:[e.jsx("div",{className:"text-xl mb-1",children:r.icon}),e.jsx("div",{className:"text-[13px] font-bold text-gray-900",children:r.name}),e.jsxs("div",{className:"text-[11px] text-gray-500 mt-0.5",children:["교사: ",r.teacherName]}),e.jsxs("div",{className:"text-[11px] text-amber-600 mt-1 font-medium",children:["신청 ",i.length,"명"]})]},r.id)})})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-4",children:[e.jsxs("h3",{className:"text-[14px] font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-amber-600"}),"최근 공지사항"]}),l.length===0?e.jsx("div",{className:"text-center py-8 text-gray-400 text-[13px]",children:"공지사항이 없습니다"}):e.jsx("div",{className:"space-y-2",children:l.slice(0,5).map(r=>e.jsxs("div",{className:"flex items-center gap-3 p-2.5 bg-gray-50 rounded-lg",children:[e.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded ${r.category==="중요"?"bg-red-100 text-red-700":r.category==="수업안내"?"bg-blue-100 text-blue-700":r.category==="행사"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"}`,children:r.category}),e.jsx("span",{className:"text-[13px] text-gray-900 font-medium flex-1 truncate",children:r.title}),r.pinned&&e.jsx("span",{className:"text-[10px] text-amber-600 font-bold",children:"고정"})]},r.id))})]})]})}function ze({enrollments:t,classes:d,onReload:s}){const[l,o]=n.useState(""),[a,x]=n.useState("all"),[h,r]=n.useState(!1),[i,u]=n.useState(!1),y=t.filter(c=>!(a!=="all"&&c.status!==a||l&&!c.name.includes(l)&&!c.phone.includes(l))),p=async(c,f)=>{try{await oe.updateStatus(c,f),v.success(`${fe[f]} 처리되었습니다`),s()}catch{v.error("상태 변경 실패")}},m=async c=>{if(confirm(`"${c.name}" 님의 수강신청을 삭제하시겠습니까?`))try{await oe.remove(c.id),v.success("삭제되었습니다"),s()}catch{v.error("삭제 실패")}};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-white rounded-lg border px-3 py-2.5 flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-[200px]",children:[e.jsx($e,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}
1),e.jsx("input",{type:"text",placeholder:"이름/전화번호 검색",value:l,onChange:c=>o(c.target.value),className:"w-full pl-8 pr-2 py-1.5 border rounded text-[12px] focus:outline-none focus:ring-1 focus:ring-amber-400"})]}),e.jsxs("select",{value:a,onChange:c=>x(c.target.value),className:"border rounded px-2 py-1.5 text-[12px] focus:outline-none focus:ring-1 focus:ring-amber-400",children:[e.jsx("option",{value:"all",children:"전체 상태"}),e.jsx("option",{value:"pending",children:"대기"}),e.jsx("option",{value:"approved",children:"승인"}),e.jsx("option",{value:"rejected",children:"거절"})]}),e.jsxs("div",{className:"text-[12px] text-gray-500 ml-auto",children:["총 ",e.jsx("strong",{className:"text-gray-800",children:y.length}),"건"]}),e.jsxs("button",{onClick:()=>u(!0),className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 text-white rounded text-[12px] font-medium hover:bg-blue-700 transition-colors",title:"수강생에게 푸시 발송",children:[e.jsx(le,{className:"w-3.5 h-3.5"}),"푸시 발송"]}),e.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-1 px-3 py-1.5 bg-amber-600 text-white rounded text-[12px] font-medium hover:bg-amber-700 transition-colors",children:[e.jsx(Se,{className:"w-3.5 h-3.5"}),"수강생 추가"]})]}),y.length===0?e.jsxs("div",{className:"bg-white rounded-lg border text-center py-16 text-gray-400 text-[13px]",children:[e.jsx(pe,{className:"w-10 h-10 mx-auto mb-3 text-gray-300"}),"수강신청이 없습니다"]}):e.jsx("div",{className:"bg-white rounded-lg border overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-100 border-b border-gray-300",children:[e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200 w-8",children:"#"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200",children:"이름"}),e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 border-r border-gray-200 w-12",children:"성별"}),e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 border-r border-gray-200 w-16",children:"출생"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200 w-[120px]",children:"연락처"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200",children:"주소"}),e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 border-r border-gray-200 w-16",children:"희망반"}),e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 border-r border-gray-200 w-14",children:"교통"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200 w-[100px]",children:"비상연락"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200",children:"건강"}),e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 border-r border-gray-200 w-12",children:"상태"}),e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 w-[100px]",children:"관리"})]})}),e.jsx("tbody",{children:y.map((c,f)=>e.jsxs("tr",{className:`border-b border-gray-200 hover:bg-amber-50/40 transition-colors ${f%2===1?"bg-gray-50/50":""}`,children:[e.jsx("td",{className:"px-2.5 py-1.5 text-[11px] text-gray-400 border-r border-gray-100",children:f+1}),e.jsx("td",{className:"px-2.5 py-1.5 border-r border-gray-100",children:e.jsx("span",{className:"text-[12px] font-semibold text-gray-900",children:c.name})}),e.jsx("td",{className:"px-2.5 py-1.5 text-center text-[12px] text-gray-700 border-r border-gray-100",children:c.gender}),e.jsx("td",{className:"px-2.5 py-1.5 text-center text-[12px] text-gray-600 border-r border-gray-100",children:c.birthYear}),e.jsx("td",{className:"px-2.5 py-1.5 text-[12px] text-gray-700 border-r border-gray-100",children:c.phone}),e.jsx("td",{className:"px-2.5 py-1.5 text-[11px] text-gray-500 border-r border-gray-100 truncate max-w-[180px]",children:c.address||"-"}),e.jsx("td",{className:"px-2.5 py-1.5 text-center text-[12px] text-gray-700 border-r border-gray-100",children:c.preferredClass||"-"}),e.jsx("td",{className:"px-2.5 py-1.5 text-center text-[11px] text-gray-600 border-r border-gray-100",children:c.transport||"-"}),e.jsx("td",{className:"px-2.5 py-1.5 text-[11px] text-gray-500 border-r border-gray-100",children:c.emergencyName?`${c.emergencyName} ${c.emergencyPhone||""}`:"-"}),e.jsx("td",{className:"px-2.5 py-1.5 text-[11px] text-gray-500 border-r border-gray-100 truncate max-w-[120px]",children:c.healthNote||"-"}),e.jsx("td",{className:"px-2.5 py-1.5 text-center border-r border-gray-100",children:e.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-[10px] font-bold ${c.status==="approved"?"bg-green-100 text-green-700":c.status==="rejected"?"bg-red-100 text-red-700":"bg-amber-100 text-amber-700"}`,children:fe[c.status]})}),e.jsx("td",{className:"px-1.5 py-1.5 text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[c.status!=="approved"&&e.jsx("button",{onClick:()=>p(c.id,"approved"),className:"p-1 text-green-600 hover:bg-green-50 rounded transition-colors",title:"승인",children:e.jsx(ve,{className:"w-3.5 h-3.5"})}),c.status!=="rejected"&&e.jsx("button",{onClick:()=>p(c.id,"rejected"),className:"p-1 text-red-500 hover:bg-red-50 rounded transition-colors",title:"거절",children:e.jsx(Te,{className:"w-3.5 h-3.5"})}),c.status!=="pending"&&e.jsx("button",{onClick:()=>p(c.id,"pending"),className:"p-1 text-amber-500 hover:bg-amber-50 rounded transition-colors",title:"대기",children:e.jsx(re,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>m(c),className:"p-1 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded transition-colors",title:"삭제",children:e.jsx(Q,{className:"w-3.5 h-3.5"})})]})})]},c.id))})]})})}),h&&e.jsx(Ue,{classes:d,onClose:()=>r(!1),onSave:()=>{r(!1),s()}}),i&&e.jsx(Ae,{targetLabel:"수강생",memberIds:t.filter(c=>c.memberId).map(c=>c.memberId),totalCount:t.length,linkedCount:t.filter(c=>c.memberId).length,onClose:()=>u(!1)})]})}function Ue({classes:t,onClose:d,onSave:s}){var F;const[l,o]=n.useState(""),[a,x]=n.useState("여"),[h,r]=n.useState(""),[i,u]=n.useState(""),[y,p]=n.useState(""),[m,c]=n.useState(((F=t[0])==null?void 0:F.name)||""),[f,w]=n.useState(""),[C,S]=n.useState(""),[b,_]=n.useState(""),[$,E]=n.useState(""),[g,A]=n.useState(),[T,M]=n.useState(!1),N=j=>{if(A(j.id),o(j.name||""),x(j.gender||"여"),j.birth_date){const G=j.birth_date.substring(0,4);G&&!isNaN(Number(G))&&r(G)}u(j.mobile_phone||j.phone||""),p(j.address_full||"")},O=async()=>
1{if(!l.trim()||!i.trim()){v.error("이름과 연락처는 필수입니다");return}M(!0);try{await oe.create({name:l,gender:a,birthYear:h,phone:i,address:y||void 0,preferredClass:m,emergencyName:f||void 0,emergencyPhone:C||void 0,healthNote:b||void 0,transport:$||void 0,status:"approved",year:new Date().getFullYear(),memberId:g}),v.success("수강생이 추가되었습니다"),s()}catch{v.error("추가 실패")}finally{M(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-xl p-5 w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-[15px] font-bold flex items-center gap-2",children:[e.jsx(Se,{className:"w-4 h-4 text-amber-600"}),"수강생 추가"]}),e.jsx("button",{onClick:d,className:"p-1 hover:bg-gray-100 rounded-md",children:e.jsx(z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"mb-4 p-3 bg-amber-50 rounded-lg border border-amber-200",children:[e.jsx("label",{className:"block text-[11px] font-bold text-amber-700 mb-1.5",children:"교적부에서 가져오기"}),e.jsx(De,{onSelect:N,placeholder:"이름 또는 전화번호로 검색..."}),e.jsx("p",{className:"text-[10px] text-amber-600 mt-1",children:"교적부에서 선택하면 기본 정보가 자동으로 채워집니다"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"이름 *"}),e.jsx("input",{value:l,onChange:j=>o(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"홍길동"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"성별"}),e.jsxs("select",{value:a,onChange:j=>x(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",children:[e.jsx("option",{value:"남",children:"남"}),e.jsx("option",{value:"여",children:"여"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"출생연도"}),e.jsx("input",{value:h,onChange:j=>r(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"1950"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"연락처 *"}),e.jsx("input",{value:i,onChange:j=>u(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"010-1234-5678"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"주소"}),e.jsx("input",{value:y,onChange:j=>p(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"수원시 ..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"희망반"}),e.jsxs("select",{value:m,onChange:j=>c(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",children:[t.map(j=>e.jsxs("option",{value:j.name,children:[j.icon," ",j.name]},j.id)),e.jsx("option",{value:"",children:"미정"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"교통편"}),e.jsxs("select",{value:$,onChange:j=>E(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",children:[e.jsx("option",{value:"",children:"선택"}),e.jsx("option",{value:"자가용",children:"자가용"}),e.jsx("option",{value:"교회차량",children:"교회차량"}),e.jsx("option",{value:"대중교통",children:"대중교통"}),e.jsx("option",{value:"도보",children:"도보"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"비상연락 이름"}),e.jsx("input",{value:f,onChange:j=>w(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"보호자 이름"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"비상연락 전화"}),e.jsx("input",{value:C,onChange:j=>S(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"010-0000-0000"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"건강 참고사항"}),e.jsx("input",{value:b,onChange:j=>_(j.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"특이사항 없음"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{onClick:d,className:"flex-1 px-3 py-2 border rounded-lg text-[12px] font-medium text-gray-600 hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:O,disabled:T,className:"flex-1 px-3 py-2 bg-amber-600 text-white rounded-lg text-[12px] font-medium hover:bg-amber-700 disabled:opacity-50",children:T?"저장 중...":"수강생 추가"})]})]})})}function He({classes:t,staffList:d,onReload:s}){const[l,o]=n.useState(!1),[a,x]=n.useState(null),h=async i=>{if(confirm(`"${i.name}" 반을 삭제하시겠습니까?`))try{await ne.remove(i.id),v.success("삭제되었습니다"),s()}catch{v.error("삭제 실패")}},r=i=>i.teacherNames&&i.teacherNames.length>0?i.teacherNames.join(", "):i.teacherName||"-";return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-white rounded-xl border p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-[13px] text-gray-500",children:["전체 ",e.jsx("strong",{className:"text-gray-800",children:t.length}),"개 반"]}),e.jsxs("button",{onClick:()=>{o(!0),x(null)},className:"flex items-center gap-1.5 px-4 py-2 bg-amber-600 text-white rounded-lg text-[13px] font-medium hover:bg-amber-700 shadow-sm transition-colors",children:[e.jsx(xe,{className:"w-4 h-4"}),"반 추가"]})]})}),t.length===0&&!l?e.jsxs("div",{className:"bg-white rounded-xl border text-center py-16 text-gray-400 text-[13px]",children:[e.jsx(X,{className:"w-10 h-10 mx-auto mb-3 text-gray-300"}),"등록된 반이 없습니다"]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:t.map(i=>e.jsxs("div",{className:"bg-white rounded-xl border p-5 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-3xl",children:i.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-bold text-gray-900",children:i.name}),e.jsxs("div",{className:"text-[13px] text-gray-500 mt-0.5",children:["담임교사: ",e.jsx("strong",{className:"text-gray-700",children:r(i)})]})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>{x(i),o(!1)},className:"p-1.5 text-gray-400 hover:text-amber-600 hover:bg-amber-50 rounded-md transition-colors",children:e.jsx(ue,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>h(i),className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-md transition-colors",children:e.jsx(Q,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-[11px] text-gray-400 mt-2",children:["순서: ",i.sortOrder]})]},i.id))}),(l||a)&&e.jsx(Ge,{item:a,staffList:d,nextOrder:t.length+1,onClose:()=>{o(!1),x(null)},onSave:()=>{o(!1),x(null),s()}})]})}function Ge({item:t,staffList:d,nextOrder:s,onClose:l,onSave:o}){const[a,x]=n.useState((t==null?void 0:t.name)||""),[h,r]=n.useState(""),[i,u]=n.useState(!1),[y,p]=n.useState((t==null?void 0:t.icon)||"🌼"),[m,c]=n.useState((t==null?void 0:t.teacherNames)||
1(t!=null&&t.teacherName?[t.teacherName]:[])),[f,w]=n.useState(!1),[C,S]=n.useState((t==null?void 0:t.sortOrder)??s),[b,_]=n.useState(!1);n.useEffect(()=>{t!=null&&t.name&&!je.includes(t.name)&&(u(!0),r(t.name))},[t]);const $=async()=>{const g=i?h.trim():a;if(!g){v.error("반 이름을 선택하세요");return}if(m.length===0){v.error("담임교사를 선택하세요");return}_(!0);try{const A={name:g,icon:y,teacherName:m.join(", "),teacherNames:m,sortOrder:C};t?await ne.update(t.id,A):await ne.create(A),v.success(t?"수정되었습니다":"추가되었습니다"),o()}catch{v.error("저장 실패")}finally{_(!1)}},E=g=>{c(A=>A.includes(g)?A.filter(T=>T!==g):[...A,g])};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:l,children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-md",onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-[16px] font-bold",children:t?"반 수정":"반 추가"}),e.jsx("button",{onClick:l,className:"p-1 hover:bg-gray-100 rounded-md",children:e.jsx(z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"아이콘"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:qe.map(g=>e.jsx("button",{onClick:()=>p(g),className:`text-2xl p-2 rounded-lg border-2 transition-colors ${y===g?"border-amber-500 bg-amber-50":"border-gray-200 hover:border-gray-300"}`,children:g},g))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"반 이름"}),i?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:h,onChange:g=>r(g.target.value),className:"flex-1 border rounded-lg px-3 py-2 text-[13px]",placeholder:"반 이름 입력",autoFocus:!0}),e.jsx("button",{onClick:()=>{u(!1),r(""),x("")},className:"px-3 py-2 border rounded-lg text-[12px] text-gray-500 hover:bg-gray-50",children:"목록"})]}):e.jsxs("select",{value:a,onChange:g=>{if(g.target.value==="__custom__"){u(!0),x("");return}x(g.target.value)},className:"w-full border rounded-lg px-3 py-2 text-[13px] bg-white",children:[e.jsx("option",{value:"",children:"선택하세요"}),je.map(g=>e.jsx("option",{value:g,children:g},g)),e.jsx("option",{value:"__custom__",children:"직접 입력..."})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:["담임교사 ",e.jsx("span",{className:"text-gray-400",children:"(봉사자 중 복수선택)"})]}),m.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:m.map(g=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 bg-amber-50 text-amber-700 rounded-full text-[12px] font-medium border border-amber-200",children:[g,e.jsx("button",{onClick:()=>E(g),className:"hover:text-red-500",children:e.jsx(z,{className:"w-3 h-3"})})]},g))}),e.jsxs("button",{onClick:()=>w(!f),className:"w-full border rounded-lg px-3 py-2 text-[13px] text-left bg-white hover:bg-gray-50 flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-400",children:m.length>0?`${m.length}명 선택됨`:"봉사자를 선택하세요"}),e.jsx(Ie,{className:`w-4 h-4 text-gray-400 transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsx("div",{className:"mt-1 border rounded-lg max-h-48 overflow-y-auto bg-white shadow-lg",children:d.length===0?e.jsx("div",{className:"px-3 py-4 text-[12px] text-gray-400 text-center",children:"등록된 봉사자가 없습니다"}):d.map(g=>e.jsxs("label",{className:"flex items-center gap-2.5 px-3 py-2 hover:bg-amber-50 cursor-pointer border-b last:border-b-0",children:[e.jsx("input",{type:"checkbox",checked:m.includes(g.name),onChange:()=>E(g.name),className:"w-4 h-4 rounded border-gray-300 text-amber-600 focus:ring-amber-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] text-gray-900",children:g.name}),g.role&&e.jsxs("span",{className:"text-[11px] text-gray-400 ml-1.5",children:["(",g.role,")"]})]})]},g.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"순서"}),e.jsx("input",{type:"number",value:C,onChange:g=>S(Number(g.target.value)),className:"w-full border rounded-lg px-3 py-2 text-[13px]"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-5",children:[e.jsx("button",{onClick:l,className:"flex-1 px-4 py-2.5 border rounded-lg text-[13px] font-medium text-gray-600 hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:$,disabled:b,className:"flex-1 px-4 py-2.5 bg-amber-600 text-white rounded-lg text-[13px] font-medium hover:bg-amber-700 disabled:opacity-50",children:b?"저장 중...":t?"수정":"추가"})]})]})})}function Ke({staffList:t,positionMap:d,onReload:s}){const[l,o]=n.useState(!1),[a,x]=n.useState(null),[h,r]=n.useState(!1),i=async u=>
1{if(confirm(`"${u.name}" 봉사자를 삭제하시겠습니까?`))try{await de.remove(u.id),v.success("삭제되었습니다"),s()}catch{v.error("삭제 실패")}};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-white rounded-lg border px-3 py-2.5 flex items-center justify-between",children:[e.jsxs("div",{className:"text-[12px] text-gray-500",children:["전체 ",e.jsx("strong",{className:"text-gray-800",children:t.length}),"명"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 text-white rounded text-[12px] font-medium hover:bg-blue-700 transition-colors",title:"봉사자에게 푸시 발송",children:[e.jsx(le,{className:"w-3.5 h-3.5"}),"푸시 발송"]}),e.jsxs("button",{onClick:()=>{o(!0),x(null)},className:"flex items-center gap-1 px-3 py-1.5 bg-amber-600 text-white rounded text-[12px] font-medium hover:bg-amber-700 transition-colors",children:[e.jsx(xe,{className:"w-3.5 h-3.5"}),"봉사자 추가"]})]})]}),t.length===0&&!l?e.jsxs("div",{className:"bg-white rounded-lg border text-center py-16 text-gray-400 text-[13px]",children:[e.jsx(he,{className:"w-10 h-10 mx-auto mb-3 text-gray-300"}),"등록된 봉사자가 없습니다"]}):e.jsx("div",{className:"bg-white rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-100 border-b border-gray-300",children:[e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 border-r border-gray-200 w-8",children:"#"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200 w-[120px]",children:"직분/역할"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200",children:"이름"}),e.jsx("th",{className:"px-2.5 py-2 text-left text-[11px] font-bold text-gray-700 border-r border-gray-200 w-[120px]",children:"연락처"}),e.jsx("th",{className:"px-2.5 py-2 text-center text-[11px] font-bold text-gray-700 w-[80px]",children:"관리"})]})}),e.jsx("tbody",{children:t.map((u,y)=>e.jsxs("tr",{className:`border-b border-gray-200 hover:bg-amber-50/40 transition-colors ${y%2===1?"bg-gray-50/50":""}`,children:[e.jsx("td",{className:"px-2.5 py-1.5 text-center text-[11px] text-gray-400 border-r border-gray-100",children:u.sortOrder}),e.jsx("td",{className:"px-2.5 py-1.5 border-r border-gray-100",children:e.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded bg-amber-100 text-amber-700 text-[11px] font-medium",children:u.role})}),e.jsxs("td",{className:"px-2.5 py-1.5 text-[12px] font-semibold text-gray-900 border-r border-gray-100",children:[u.name,u.memberId&&d[u.memberId]&&e.jsx("span",{className:"ml-1 text-[10px] font-normal text-gray-500",children:d[u.memberId]})]}),e.jsx("td",{className:"px-2.5 py-1.5 text-[12px] text-gray-600 border-r border-gray-100",children:u.phone||"-"}),e.jsx("td",{className:"px-1.5 py-1.5 text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{onClick:()=>{x(u),o(!1)},className:"p-1 text-gray-400 hover:text-amber-600 hover:bg-amber-50 rounded transition-colors",children:e.jsx(ue,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>i(u),className:"p-1 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded transition-colors",children:e.jsx(Q,{className:"w-3.5 h-3.5"})})]})})]},u.id))})]})}),(l||a)&&e.jsx(Xe,{item:a,nextOrder:t.length+1,onClose:()=>{o(!1),x(null)},onSave:()=>{o(!1),x(null),s()}}),h&&e.jsx(Ae,{targetLabel:"봉사자",memberIds:t.filter(u=>u.memberId).map(u=>u.memberId),totalCount:t.length,linkedCount:t.filter(u=>u.memberId).length,onClose:()=>r(!1)})]})}function Xe({item:t,nextOrder:d,onClose:s,onSave:l}){const[o,a]=n.useState((t==null?void 0:t.role)||""),[x,h]=n.useState((t==null?void 0:t.name)||""),[r,i]=n.useState((t==null?void 0:t.phone)||""),[u,y]=n.useState((t==null?void 0:t.memberId)||""),[p,m]=n.useState((t==null?void 0:t.sortOrder)??d),[c,f]=n.useState(!1),w=b=>{y(b.id),h(b.name||""),i(b.mobile_phone||b.phone||"")},C=async()=>
1{if(!o.trim()||!x.trim()){v.error("역할과 이름을 입력하세요");return}f(!0);try{const b={role:o,name:x,phone:r||void 0,memberId:u||void 0,sortOrder:p};t?await de.update(t.id,b):await de.create(b),v.success(t?"수정되었습니다":"추가되었습니다"),l()}catch{v.error("저장 실패")}finally{f(!1)}},S=["학장","교역자","팀장","담임교사","차량지도","취미반","봉사"];return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-xl p-5 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-[15px] font-bold",children:t?"봉사자 수정":"봉사자 추가"}),e.jsx("button",{onClick:s,className:"p-1 hover:bg-gray-100 rounded-md",children:e.jsx(z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"mb-4 p-3 bg-amber-50 rounded-lg border border-amber-200",children:[e.jsx("label",{className:"block text-[11px] font-bold text-amber-700 mb-1.5",children:"교적부에서 가져오기"}),e.jsx(De,{onSelect:w,placeholder:"이름 또는 전화번호로 검색..."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"직분/역할 *"}),e.jsx("input",{value:o,onChange:b=>a(b.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"예: 학장"}),e.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:S.map(b=>e.jsx("button",{onClick:()=>a(b),className:"text-[10px] px-1.5 py-0.5 bg-gray-100 hover:bg-amber-100 text-gray-600 rounded transition-colors",children:b},b))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"이름 *"}),e.jsx("input",{value:x,onChange:b=>h(b.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"예: 홍길동"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"연락처"}),e.jsx("input",{value:r,onChange:b=>i(b.target.value),className:"w-full border rounded px-2.5 py-1.5 text-[12px]",placeholder:"010-1234-5678"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"순서"}),e.jsx("input",{type:"number",value:p,onChange:b=>m(Number(b.target.value)),className:"w-full border rounded px-2.5 py-1.5 text-[12px]"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"flex-1 px-3 py-2 border rounded-lg text-[12px] font-medium text-gray-600 hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:C,disabled:c,className:"flex-1 px-3 py-2 bg-amber-600 text-white rounded-lg text-[12px] font-medium hover:bg-amber-700 disabled:opacity-50",children:c?"저장 중...":t?"수정":"추가"})]})]})})}function Qe({events:t,notices:d,onReload:s}){const[l,o]=n.useState("events");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>o("events"),className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-colors ${l==="events"?"bg-amber-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:["연중 행사 (",t.length,")"]}),e.jsxs("button",{onClick:()=>o("notices"),className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-colors ${l==="notices"?"bg-amber-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:["공지사항 (",d.length,")"]})]}),l==="events"?e.jsx(We,{events:t,onReload:s}):e.jsx(tt,{notices:d,onReload:s})]})}function We({events:t,onReload:d}){const[s,l]=n.useState("month"),[o,a]=n.useState(new Date),[x,h]=n.useState([]),[r,i]=n.useState(!1),[u,y]=n.useState(!1),[p,m]=n.useState(null),[c,f]=n.useState(""),[w,C]=n.useState([]),S=o.getFullYear(),b=o.getMonth(),_=k=>k.toString().padStart(2,"0"),$=(()=>{const P=new Date(S,b,1).getDay(),Y=new Date(S,b,1-P),me=new Date(S,b+1,6*7-P-new Date(S,b+1,0).getDate()-P+1);return{start:`${Y.getFullYear()}-${_(Y.getMonth()+1)}-${_(Y.getDate())}`,end:`${me.getFullYear()}-${_(me.getMonth()+1)}-${_(me.getDate())}`}})(),E=n.useCallback(async()=>{i(!0);try{const k=await K.getByDateRange($.start,$.end);h(k)}catch{h([])}finally{i(!1)}},[$.start,$.end]);n.useEffect(()=>{E()},[E]);const g=w.length===0?x:x.filter(k=>w.includes(k.category)),A=()=>a(new Date(S,b-1,1)),T=()=>a(new Date(S,b+1,1)),M=()=>a(new Date),N=k=>{f(k),m(null),y(!0)},O=k=>{m(k),f(""),y(!0)},F=async k=>{try{p?(await K.update(p.id,k),v.success("수정되었습니다")):(await K.create(k),v.success("추가되었습니다")),y(!1),m(null),E(),d()}catch{v.error("저장 실패")}},j=async()=>
1{if(!(!p||!confirm(`"${p.title}" 일정을 삭제하시겠습니까?`)))try{await K.remove(p.id),v.success("삭제되었습니다"),y(!1),m(null),E(),d()}catch{v.error("삭제 실패")}},G=k=>{C(P=>P.includes(k)?P.filter(Y=>Y!==k):[...P,k])};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-white rounded-xl border p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:A,className:"p-1.5 hover:bg-gray-100 rounded-lg",children:e.jsx(Me,{className:"w-5 h-5 text-gray-600"})}),e.jsxs("h2",{className:"text-[16px] font-bold text-gray-900 min-w-[120px] text-center",children:[S,"년 ",b+1,"월"]}),e.jsx("button",{onClick:T,className:"p-1.5 hover:bg-gray-100 rounded-lg",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-600"})}),e.jsx("button",{onClick:M,className:"ml-2 px-3 py-1 text-[12px] font-medium text-amber-700 bg-amber-50 border border-amber-200 rounded-lg hover:bg-amber-100",children:"오늘"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-0.5 bg-gray-100 rounded-lg p-0.5",children:[e.jsxs("button",{onClick:()=>l("month"),className:`px-3 py-1.5 text-[12px] font-medium rounded-md transition-colors ${s==="month"?"bg-white text-gray-900 shadow-sm":"text-gray-500"}`,children:[e.jsx(Ne,{className:"w-3.5 h-3.5 inline mr-1"}),"월"]}),e.jsxs("button",{onClick:()=>l("list"),className:`px-3 py-1.5 text-[12px] font-medium rounded-md transition-colors ${s==="list"?"bg-white text-gray-900 shadow-sm":"text-gray-500"}`,children:[e.jsx(Pe,{className:"w-3.5 h-3.5 inline mr-1"}),"목록"]})]}),e.jsxs("button",{onClick:()=>{m(null),f(""),y(!0)},className:"flex items-center gap-1.5 px-4 py-2 bg-amber-600 text-white rounded-lg text-[13px] font-medium hover:bg-amber-700 shadow-sm",children:[e.jsx(xe,{className:"w-4 h-4"}),"일정 추가"]})]})]})}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[ke.map(k=>{const P=H[k],Y=w.includes(k);return e.jsx("button",{onClick:()=>G(k),className:`px-2.5 py-1 text-[11px] font-medium rounded-full border transition-all ${Y?`${P.bg} ${P.text} ${P.border}`:"bg-gray-100 text-gray-500 border-gray-200 hover:bg-gray-200"}`,children:be[k]},k)}),w.length>0&&e.jsx("button",{onClick:()=>C([]),className:"px-2 py-1 text-[11px] text-gray-400 hover:text-gray-600",children:"초기화"})]}),r?e.jsx("div",{className:"bg-white rounded-xl border text-center py-16",children:e.jsx(ge,{className:"w-6 h-6 mx-auto animate-spin text-amber-500"})}):s==="month"?e.jsx(Ze,{year:S,month:b,schedules:g,onDateClick:N,onEventClick:O}):e.jsx(Je,{schedules:g,onEventClick:O}),u&&e.jsx(et,{event:p,defaultDate:c,onClose:()=>{y(!1),m(null)},onSave:F,onDelete:p?j:void 0})]})}function Ze({year:t,month:d,schedules:s,onDateClick:l,onEventClick:o}){const a=p=>p.toString().padStart(2,"0"),x=["일","월","화","수","목","금","토"],h=(()=>{const p=new Date;return`${p.getFullYear()}-${a(p.getMonth()+1)}-${a(p.getDate())}`})(),i=new Date(t,d,1).getDay();new Date(t,d+1,0).getDate();const u=[];for(let p=0;p<42;p++){const m=new Date(t,d,1-i+p);u.push({key:`${m.getFullYear()}-${a(m.getMonth()+1)}-${a(m.getDate())}`,date:m.getDate(),isCurrentMonth:m.getMonth()===d})}const y={};for(const p of s){if(!p.start_date)continue;const m=p.start_date,c=p.end_date||p.start_date;let f=new Date(m);const w=new Date(c);for(;f<=w;){const C=`${f.getFullYear()}-${a(f.getMonth()+1)}-${a(f.getDate())}`;y[C]||(y[C]=[]),y[C].push(p),f.setDate(f.getDate()+1)}}return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-gray-200",children:x.map((p,m)=>e.jsx("div",{className:`py-2 text-center text-[12px] font-medium ${m===0?"text-red-500":m===6?"text-blue-500":"text-gray-500"}`,children:p},p))}),e.jsx("div",{className:"grid grid-cols-7",children:u.map((p,m)=>{const c=y[p.key]||[],f=p.key===h,w=m%7;return e.jsxs("div",{onClick:()=>l(p.key),className:`min-h-[100px] border-b border-r border-gray-100 p-1 cursor-pointer hover:bg-amber-50/30 transition-colors ${p.isCurrentMonth?"":"bg-gray-50/50"}`,children:[e.jsx("div",{className:`w-6 h-6 flex items-center justify-center text-[12px] font-medium rounded-full mb-0.5 ${f?"bg-amber-600 text-white":p.isCurrentMonth?w===0?"text-red-500":w===6?"text-blue-500":"text-gray-700":"text-gray-300"}`,children:p.date}),e.jsxs("div",{className:"space-y-0.5",children:[c.slice(0,3).map(C=>{const S=H[C.category]||H.other;return e.jsxs("button",{onClick:b=>{b.stopPropagation(),o(C)},className:`w-full text-left px-1 py-0.5 rounded text-[10px] font-medium truncate ${S.bg} ${S.text}`,children:[!C.all_day&&C.start_time&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[C.start_time," "]}
1),C.title]},C.id)}),c.length>3&&e.jsxs("span",{className:"text-[10px] text-gray-400 pl-1",children:["+",c.length-3,"건"]})]})]},p.key)})})]})}function Je({schedules:t,onEventClick:d}){const s=r=>r.toString().padStart(2,"0"),l=(()=>{const r=new Date;return`${r.getFullYear()}-${s(r.getMonth()+1)}-${s(r.getDate())}`})(),o=["일","월","화","수","목","금","토"],a={};for(const r of t)r.start_date&&(a[r.start_date]||(a[r.start_date]=[]),a[r.start_date].push(r));const x=Object.keys(a).sort(),h=r=>{const i=new Date(r);return`${i.getMonth()+1}월 ${i.getDate()}일 (${o[i.getDay()]})`};return x.length===0?e.jsxs("div",{className:"bg-white rounded-xl border text-center py-16 text-gray-400 text-[13px]",children:[e.jsx(re,{className:"w-10 h-10 mx-auto mb-3 text-gray-300"}),"이 기간에 등록된 일정이 없습니다"]}):e.jsx("div",{className:"space-y-3",children:x.map(r=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:`px-4 py-2 border-b border-gray-100 flex items-center gap-2 ${r===l?"bg-amber-50":"bg-gray-50"}`,children:[e.jsx("span",{className:`text-[13px] font-semibold ${r===l?"text-amber-700":"text-gray-700"}`,children:h(r)}),r===l&&e.jsx("span",{className:"px-1.5 py-0.5 bg-amber-600 text-white text-[10px] rounded font-medium",children:"오늘"}),e.jsxs("span",{className:"text-[11px] text-gray-400",children:[a[r].length,"건"]})]}),e.jsx("div",{className:"divide-y divide-gray-50",children:a[r].map(i=>{const u=H[i.category]||H.other;return e.jsxs("button",{onClick:()=>d(i),className:"w-full text-left px-4 py-3 hover:bg-gray-50 flex items-start gap-3 transition-colors",children:[e.jsx("div",{className:`w-2 h-2 rounded-full mt-1.5 flex-shrink-0 ${u.dot}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:"text-[13px] font-medium text-gray-900",children:i.title}),e.jsx("span",{className:`px-1.5 py-0.5 text-[10px] font-medium rounded-full ${u.bg} ${u.text}`,children:be[i.category]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[12px] text-gray-500",children:[i.all_day?e.jsx("span",{children:"종일"}):i.start_time&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(re,{className:"w-3 h-3"}),i.start_time,i.end_time?` ~ ${i.end_time}`:""]}),i.location&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Le,{className:"w-3 h-3"}),i.location]})]}),i.description&&e.jsx("p",{className:"text-[11px] text-gray-400 mt-0.5 truncate",children:i.description})]})]},i.id)})})]},r))})}function et({event:t,defaultDate:d,onClose:s,onSave:l,onDelete:o}){const a=()=>{const N=new Date,O=F=>F.toString().padStart(2,"0");return`${N.getFullYear()}-${O(N.getMonth()+1)}-${O(N.getDate())}`},[x,h]=n.useState((t==null?void 0:t.title)||""),[r,i]=n.useState((t==null?void 0:t.description)||""),[u,y]=n.useState((t==null?void 0:t.location)||""),[p,m]=n.useState((t==null?void 0:t.start_date)||d||a()),[c,f]=n.useState((t==null?void 0:t.end_date)||d||a()),[w,C]=n.useState((t==null?void 0:t.start_time)||"10:00"),[S,b]=n.useState((t==null?void 0:t.end_time)||"12:00"),[_,$]=n.useState((t==null?void 0:t.all_day)??!1),[E,g]=n.useState((t==null?void 0:t.category)||"event"),[A,T]=n.useState(!1),M=async()=>{if(!x.trim()){v.error("일정명을 입력하세요");return}T(!0);try{await l({title:x.trim(),description:r.trim()||void 0,location:u.trim()||void 0,start_date:p,start_time:_?void 0:w,end_date:c,end_time:_?void 0:S,all_day:_,category:E})}finally{T(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40",onClick:s,children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-[16px] font-bold text-gray-900",children:t?"일정 수정":"새 일정"}),e.jsx("button",{onClick:s,className:"p-1 hover:bg-gray-100 rounded-lg",children:e.jsx(z,{className:"w-5 h-5 text-gray-500"})})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1 block",children:"일정명 *"}),e.jsx("input",{type:"text",value:x,onChange:N=>h(N.target.value),autoFocus:!0,placeholder:"일정 제목을 입력하세요",className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-[13px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1.5 block",children:"카테고리"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ke.map(N=>{const O=H[N],F=E===N;return e.jsx("button",{onClick:()=>g(N),className:`px-3 py-1 text-[12px] font-medium rounded-full border transition-all ${F?`${O.bg} ${O.text} ${O.border}`:"bg-gray-50 text-gray-500 border-gray-200"}`,children:be[N]},N)})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:N=>$(N.target.checked),className:"rounded border-gray-300 text-amber-600"}),e.jsx("span",{className:"text-[13px] text-gray-700",children:"종일"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1 block",children:"시작일"}),e.jsx("input",{type:"date",value:p,onChange:N=>{m(N.target.value),N.target.value>c&&f(N.target.value)},className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-[13px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1 block",children:"종료일"}),e.jsx("input",{type:"date",value:c,onChange:N=>f(N.target.value),min:p,className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-[13px]"})]}),!_&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1 block",children:"시작 시간"}),e.jsx("input",{type:"time",value:w,onChange:N=>C(N.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-[13px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1 block",children:"종료 시간"}),e.jsx("input",{type:"time",value:S,onChange:N=>b(N.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-[13px]"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1 block",children:"장소"}),e.jsx("input",{type:"text",value:u,onChange:N=>y(N.target.value),placeholder:"장소 (선택)",className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-[13px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[12px] font-medium text-gray-600 mb-1 block",children:"메모"}),e.jsx("textarea",{value:r,onChange:N=>i(N.target.value),placeholder:"추가 메모 (선택)",rows:2,className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-[13px] resize-none"})]})]}),e.jsxs("div",{className:"px-5 py-4 border-t border-gray-100 flex items-center justify-between",children:[e.jsx("div",{children:t&&o&&e.jsxs("button",{onClick:o,className:"px-3 py-1.5 text-[12px] text-red-600 hover:bg-red-50 rounded-lg flex items-center gap-1",children:[e.jsx(Q,{className:"w-3.5 h-3.5"})," 삭제"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 text-[13px] text-gray-600 hover:bg-gray-100 rounded-lg",children:"취소"}),e.jsx("button",{onClick:M,disabled:!x.trim()||A,className:"px-4 py-2 bg-amber-600 text-white text-[13px] font-medium rounded-lg hover:bg-amber-700 disabled:opacity-50",children:A?"저장 중...":t?"수정":"저장"})]})]})]})})}function tt({notices:t,onReload:d}){const[s,l]=n.useState(!1),[o,a]=n.useState(null),x=async h=>{if(confirm(`"${h.title}" 공지를 삭제하시겠습니까?`))try{await ce.remove(h.id),v.success("삭제되었습니다"),d()}catch{v.error("삭제 실패")}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-white rounded-xl border p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-[13px] text-gray-500",children:["전체 ",e.jsx("strong",{className:"text-gray-800",children:t.length}),"개"]}),e.jsxs("button",{onClick:()=>{l(!0),a(null)},className:"flex items-center gap-1.5 px-4 py-2 bg-amber-600 text-white rounded-lg text-[13px] font-medium hover:bg-amber-700 shadow-sm transition-colors",children:[e.jsx(xe,{className:"w-4 h-4"}),"공지 작성"]})]})}),t.length===0&&!s?e.jsxs("div",{className:"bg-white rounded-xl border text-center py-16 text-gray-400 text-[13px]",children:[e.jsx(we,{className:"w-10 h-10 mx-auto mb-3 text-gray-300"}),"공지사항이 없습니다"]}):e.jsx("div",{className:"bg-white rounded-xl border overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80",children:[e.jsx("th",{className:"px-4 py-3 text-center text-[12px] font-semibold text-gray-600 w-[80px]",children:"카테고리"}),e.jsx("th",{className:"px-4 py-3 text-left text-[12px] font-semibold text-gray-600",children:"제목"}),e.jsx("th",{className:"px-4 py-3 text-center text-[12px] font-semibold text-gray-600 w-[60
1px]",children:"고정"}),e.jsx("th",{className:"px-4 py-3 text-center text-[12px] font-semibold text-gray-600 w-[100px]",children:"작성일"}),e.jsx("th",{className:"px-4 py-3 text-center text-[12px] font-semibold text-gray-600 w-[120px]",children:"액션"})]})}),e.jsx("tbody",{children:t.map((h,r)=>e.jsxs("tr",{className:`border-b border-gray-100 hover:bg-amber-50/30 transition-colors ${r%2===1?"bg-gray-50/30":""}`,children:[e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-[11px] font-medium ${h.category==="중요"?"bg-red-100 text-red-700":h.category==="수업안내"?"bg-blue-100 text-blue-700":h.category==="행사"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"}`,children:h.category})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-gray-900",children:h.title}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5 truncate max-w-[300px]",children:h.content})]}),e.jsx("td",{className:"px-4 py-3 text-center text-[13px]",children:h.pinned?e.jsx("span",{className:"text-amber-500 font-bold",children:"Y"}):e.jsx("span",{className:"text-gray-300",children:"-"})}),e.jsx("td",{className:"px-4 py-3 text-center text-[12px] text-gray-500",children:h.createdAt?new Date(h.createdAt).toLocaleDateString("ko-KR"):"-"}),e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx("button",{onClick:()=>{a(h),l(!1)},className:"p-1.5 text-gray-400 hover:text-amber-600 hover:bg-amber-50 rounded-md transition-colors",children:e.jsx(ue,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>x(h),className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-md transition-colors",children:e.jsx(Q,{className:"w-4 h-4"})})]})})]},h.id))})]})}),(s||o)&&e.jsx(st,{item:o,onClose:()=>{l(!1),a(null)},onSave:()=>{l(!1),a(null),d()}})]})}function st({item:t,onClose:d,onSave:s}){const[l,o]=n.useState((t==null?void 0:t.title)||""),[a,x]=n.useState((t==null?void 0:t.content)||""),[h,r]=n.useState((t==null?void 0:t.category)||"일반"),[i,u]=n.useState((t==null?void 0:t.pinned)??!1),[y,p]=n.useState(!1),m=async()=>{if(!l.trim()||!a.trim()){v.error("제목과 내용을 입력하세요");return}p(!0);try{t?await ce.update(t.id,{title:l,content:a,category:h,pinned:i}):await ce.create({title:l,content:a,category:h,pinned:i}),v.success(t?"수정되었습니다":"공지가 작성되었습니다"),s()}catch{v.error("저장 실패")}finally{p(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-[16px] font-bold",children:t?"공지 수정":"공지 작성"}),e.jsx("button",{onClick:d,className:"p-1 hover:bg-gray-100 rounded-md",children:e.jsx(z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"카테고리"}),e.jsx("select",{value:h,onChange:c=>r(c.target.value),className:"w-full border rounded-lg px-3 py-2 text-[13px]",children:Ve.map(c=>e.jsx("option",{value:c,children:c},c))})]}),e.jsx("div",{className:"flex items-end pb-0.5",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:c=>u(c.target.checked),className:"w-4 h-4 text-amber-600 rounded border-gray-300"}),e.jsx("span",{className:"text-[13px] font-medium text-gray-600",children:"상단 고정"})]})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"제목"}),e.jsx("input",{value:l,onChange:c=>o(c.target.value),className:"w-full border rounded-lg px-3 py-2 text-[13px]",placeholder:"공지 제목"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-600 mb-1",children:"내용"}),e.jsx("textarea",{value:a,onChange:c=>x(c.target.value),className:"w-full border rounded-lg px-3 py-2 text-[13px] h-40 resize-y",placeholder:"공지 내용을 입력하세요"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-5",children:[e.jsx("button",{onClick:d,className:"flex-1 px-4 py-2.5 border rounded-lg text-[13px] font-medium text-gray-600 hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:m,disabled:y,className:"flex-1 px-4 py-2.5 bg-amber-600 text-white rounded-lg text-[13px] font-medium hover:bg-amber-700 disabled:opacity-50",children:y?"저장 중...":t?"수정":"작성"})]})]})})}function Ae({targetLabel:t,memberIds:d,totalCount:s,linkedCount:l,onClose:o}){const{user:a}=Ye(),[x,h]=n.useState(""),[r,i]=n.useState(""),[u,y]=n.useState(!1),p=async()=>
1{if(!x.trim()||!r.trim()){v.error("제목과 내용을 입력하세요");return}if(d.length===0){v.error("교적부에 연동된 대상이 없어 발송할 수 없습니다");return}y(!0);try{const m=await ye.createPush({title:x,body:r,status:"draft",category:"content",link_url:"/silver/index.html",link_type:"internal",target_config:{mode:"individual",individual:{member_ids:d}},created_by:(a==null?void 0:a.uid)||"admin"});await ye.sendNow(m),v.success(`${t} ${d.length}명에게 푸시를 발송했습니다`),o()}catch(m){v.error((m==null?void 0:m.message)||"푸시 발송 실패")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-xl p-5 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-[15px] font-bold flex items-center gap-2",children:[e.jsx(le,{className:"w-4 h-4 text-blue-600"}),t," 푸시 발송"]}),e.jsx("button",{onClick:o,className:"p-1 hover:bg-gray-100 rounded-md",children:e.jsx(z,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"mb-4 p-3 bg-blue-50 rounded-lg border border-blue-200",children:e.jsxs("div",{className:"text-[12px] text-blue-700",children:[e.jsx("strong",{children:"발송 대상:"})," 교적부 연동된 ",t," ",e.jsxs("strong",{children:[l,"명"]}),l<s&&e.jsxs("span",{className:"text-blue-500",children:[" (전체 ",s,"명 중 ",s-l,"명은 교적부 미연동)"]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"제목 *"}),e.jsx("input",{value:x,onChange:m=>h(m.target.value),className:"w-full border rounded px-2.5 py-2 text-[13px]",placeholder:"예: 실버대학 안내"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-600 mb-1",children:"내용 *"}),e.jsx("textarea",{value:r,onChange:m=>i(m.target.value),className:"w-full border rounded px-2.5 py-2 text-[13px] h-24 resize-y",placeholder:"알림 내용을 입력하세요"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{onClick:o,className:"flex-1 px-3 py-2 border rounded-lg text-[12px] font-medium text-gray-600 hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:p,disabled:u||d.length===0,className:"flex-1 px-3 py-2 bg-blue-600 text-white rounded-lg text-[12px] font-medium hover:bg-blue-700 disabled:opacity-50 flex items-center justify-center gap-1.5",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"})," 발송 중..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3.5 h-3.5"})," 발송하기"]})})]})]})})}export{xt as SilverUniversityPage};

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.