PageSourceSearch

https://seodoon-church-admin.web.app/assets/NewMemberManagementPage-EkqVUAi6.js

js seodoon-church-admin.web.app collected 2026-10-03 12:35:33 UTC 55,651 bytes, 4 lines download raw bytes

1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as c}from"./vendor-react-zNM0AU50.js";import{U as ze,a5 as $e,s as We,e as Ge,K as He,z as u,X as V,n as qe,r as mt,H as ht,$ as ut,ag as Ke,a as Xe,ah as gt,c as Je,ai as pt,d as be,aa as bt,T as Me,E as ne,g as Qe,A as ft,h as jt,a8 as Ce,aj as Le,O as yt,ak as Nt,al as wt,Y as vt}from"./vendor-ui-CW5bJ11U.js";import{s as fe,d as g,u as St}from"./index-D1K3lVhu.js";import{u as z,k as E,y as ie,D as je,G as ye,E as Ne,z as se,l as $,j as kt,q as W,x as J,w as F,m as _,A as R,H as Ct}from"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";const At=["새가족교육 1주차","새가족교육 2주차","새가족교육 3주차","새가족교육 4주차","성경공부 입문","세례교육"],Dt=["첫방문","정기심방","특별심방","전화심방"],Mt=["장년부","청년부","중고등부","교회학교"],v="newMembers";function oe(s){const l={};for(const[r,d]of Object.entries(s))d!==void 0&&(l[r]=d);return l}const q={async getAll(){const s=W($(g,v),J("registeredAt","desc"));return(await _(s)).docs.map(r=>({id:r.id,...r.data()}))},async getByYear(s){const l=new Date(s,0,1),r=new Date(s,11,31,23,59,59),d=W($(g,v),F("registeredAt",">=",l),F("registeredAt","<=",r),J("registeredAt","desc"));return(await _(d)).docs.map(p=>({id:p.id,...p.data()}))},async getByStatus(s){const l=W($(g,v),F("status","==",s),J("registeredAt","desc"));return(await _(l)).docs.map(d=>({id:d.id,...d.data()}))},async getById(s){const l=await kt(E(g,v,s));return l.exists()?{id:l.id,...l.data()}:null},async create(s,l){let r=[];if(l&&l.length>0)for(const p of l){const S=je(fe,`newMembers/${Date.now()}_${p.name}`);await ye(S,p);const x=await Ne(S);r.push(x)}const d=oe({...s,photoUrl:r[0]||s.photoUrl||"",photoUrls:r.length>0?r:s.photoUrls||[],status:s.status||"신규",isPublic:s.isPublic!==!1,createdAt:R(),updatedAt:R()});return(await se($(g,v),d)).id},async update(s,l,r){const d={...oe(l),updatedAt:R()};if(r&&r.length>0){const j=[];for(const S of r){const x=je(fe,`newMembers/${Date.now()}_${S.name}`);await ye(x,S);const b=await Ne(x);j.push(b)}const p=l.photoUrls||[];d.photoUrls=[...p,...j],d.photoUrl=d.photoUrls[0]||""}await z(E(g,v,s),d)},async delete(s){await ie(E(g,v,s))},async updateStatus(s,l){await z(E(g,v,s),{status:l,updatedAt:R()})},getPhotoUrls(s){return s.photoUrls&&s.photoUrls.length>0?s.photoUrls:s.photoUrl?[s.photoUrl]:[]}},he={async getAll(s){const l=$(g,v,s,"education");return(await _(l)).docs.map(d=>({id:d.id,...d.data()}))},async initCourses(s){if((await this.getAll(s)).length>0)return;const r=Ct(g);for(const d of At){const j=E($(g,v,s,"education"));r.set(j,{courseName:d,isCompleted:!1,createdAt:R()})}await r.commit()},async toggleCourse(s,l,r){const d=E(g,v,s,"education",l);await z(d,{isCompleted:r,completedAt:r?R():null})},async addCourse(s,l){return(await se($(g,v,s,"education"),{...oe(l),createdAt:R()})).id},async deleteCourse(s,l){await ie(E(g,v,s,"education",l))}},Ae={async getAll(s){const l=$(g,v,s,"visits"),r=W(l,J("visitDate","desc"));return(await _(r)).docs.map(j=>({id:j.id,...j.data()}))},async add(s,l){return(await se($(g,v,s,"visits"),{...oe(l),createdAt:R()})).id},async update(s,l,r){await z(E(g,v,s,"visits",l),oe(r))},async delete(s,l){await ie(E(g,v,s,"visits",l))}},Ye={async assign(s,l,r){await z(E(g,v,s),{mentorId:l,mentorName:r,updatedAt:R()})},async unassign(s){await z(E(g,v,s),{mentorId:null,mentorName:null,updatedAt:R()})},async getUnassigned(){return(await q.getAll()).filter(l=>!l.mentorId&&l.status!=="정착완료"&&l.status!=="이탈")}
1,async getByMentor(s){const l=W($(g,v),F("mentorId","==",s));return(await _(l)).docs.map(d=>({id:d.id,...d.data()}))}},$t={async getPromotionCandidates(){const s=W($(g,v),F("status","==","정착완료"));return(await _(s)).docs.map(r=>({id:r.id,...r.data()})).filter(r=>!r.promotedToMemberId)},async promoteToMember(s,l){const r=await se($(g,"members"),{...l,member_classification:"새가족",source:"new_member_promotion",sourceNewMemberId:s,createdAt:R(),updatedAt:R()});return await z(E(g,v,s),{promotedToMemberId:r.id,updatedAt:R()}),r.id}},Ut={async getStats(){var S;const s=await q.getAll(),l={신규:0,교육중:0,정착중:0,정착완료:0,이탈:0},r={};for(const x of s){const b=x.status||"신규";l[b]=(l[b]||0)+1;const I=(S=x.registeredAt)!=null&&S.toDate?x.registeredAt.toDate():x.registeredAt?new Date(x.registeredAt):null;if(I){const w=I.getFullYear();r[w]=(r[w]||0)+1}}const d=s.length-l.신규,j=d>0?Math.round(l.정착완료/d*100):0,p=s.filter(x=>!x.mentorId&&x.status!=="정착완료"&&x.status!=="이탈").length;return{total:s.length,byStatus:l,byYear:r,settlementRate:j,educationCompletionRate:0,noMentorCount:p}}},Pt={신규:"bg-blue-100 text-blue-700",교육중:"bg-yellow-100 text-yellow-700",정착중:"bg-emerald-100 text-emerald-700",정착완료:"bg-green-100 text-green-700",이탈:"bg-red-100 text-red-700"},Tt={신규:"bg-blue-500",교육중:"bg-yellow-500",정착중:"bg-emerald-500",정착완료:"bg-green-500",이탈:"bg-red-500"};function Rt(){const[s,l]=c.useState(null),[r,d]=c.useState(!0);c.useEffect(()=>{j()},[]);const j=async()=>{try{const x=await Ut.getStats();l(x)}catch(x){console.error("통계 로드 실패:",x)}finally{d(!1)}};if(r)return e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})});if(!s)return e.jsx("div",{className:"text-center py-10 text-gray-400",children:"통계 데이터를 불러올 수 없습니다."});const p=Object.entries(s.byYear).sort(([x],[b])=>Number(b)-Number(x)),S=Math.max(...Object.values(s.byYear),1);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(ue,{icon:ze,label:"전체 새가족",value:s.total,color:"blue"}),e.jsx(ue,{icon:$e,label:"정착 완료",value:s.byStatus.정착완료,color:"green"}),e.jsx(ue,{icon:We,label:"정착률",value:`${s.settlementRate}%`,color:"emerald"}),e.jsx(ue,{icon:Ge,label:"담당자 미배정",value:s.noMentorCount,color:"orange",alert:s.noMentorCount>0})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-5 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(He,{className:"w-5 h-5 text-blue-600"})," 상태별 분포"]}),e.jsx("div",{className:"space-y-3",children:Object.entries(s.byStatus).map(([x,b])=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium w-20 text-center ${Pt[x]}`,children:x}),e.jsx("div",{className:"flex-1 bg-gray-100 rounded-full h-6 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 flex items-center justify-end pr-2 ${Tt[x]}`,style:{width:`${s.total>0?b/s.total*100:0}%`,minWidth:b>0?"32px":"0"},children:b>0&&e.jsx("span",{className:"text-white text-xs font-bold",children:b})})}),e.jsxs("span",{className:"text-sm text-gray-500 w-10 text-right",children:[b,"명"]})]},x))})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-5 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(We,{className:"w-5 h-5 text-emerald-600"})," 년도별 새가족 수"]}),p.length===0?e.jsx("p",{className:"text-gray-400 text-sm",children:"데이터가 없습니다."}):e.jsx("div",{className:"space-y-2",children:p.map(([x,b])=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 w-14",children:[x,"년"]}),e.jsx("div",{className:"flex-1 bg-gray-100 rounded-full h-7 overflow-hidden",children:e.jsx("div",{className:"h-full bg-blue-600 rounded-full transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${b/S*100}%`,minWidth:"40px"},children:e.jsxs("span",{className:"text-white text-xs font-bold",children:[b,"명"]})})})]},x))})]})]})}function ue({icon:s,label:l,value:r,color:d,alert:j}){const p={blue:"bg-blue-50 text-blue-600",green:"bg-green-50 text-green-600",emerald:"bg-emerald-50 text-emerald-600",orange:"bg-orange-50 text-orange-600"};return e.jsxs("div",{className:`bg-white rounded-xl border p-4 shadow-sm ${j?"ring-2 ring-orange-300":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg ${p[d]} flex items-center justify-center`,children:e.jsx(s,{className:"w-4.5 h-4.5"})}),j&&e.jsx("span",{className:"w-2 h-2 bg-orange-500 rounded-full animate-pulse"})]}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 tabular-nums",children:r}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:l})]})}const Et=["신규","교육중","정착중","정착완료","이탈"],Be=["1단계-첫방문","2단계-교육","3단계-소그룹","4단계-봉사","5단계-정착완료"],Ve={신규:"bg-blue-100 text-blue-700 border-blue-200",교육중:"bg-yellow-100 text-yellow-700 border-yellow-200",정착중:"bg-emerald-100 text-emerald-700 border-emerald-200",정착완료:"bg-green-100 text-green-700 border-green-200",이탈:"bg-red-100 text-red-700 border-red-200"};function It({member:s,onClose:l,onUpdate:r}){const[d,j]=c.useState("info"),[p,S]=c.useState([]),[x,b]=c.useState([]),[I,w]=c.useState(!1),[o,C]=c.useState(0),[T,Y]=c.useState(!1),[D,U]=c.useState({visitDate:new Date().toISOString().slice(0,10),visitor:"",type:"정기심방",content:"",followUpRequired:!1}),M=q.getPhotoUrls(s);c.useEffect(()=>{d==="education"&&G(),d==="visit"&&B()},[d]);const G=async()=>{w(!0);try{let a=await he.getAll(s.id);a.length===0&&(await he.initCourses(s.id),a=await he.getAll(s.id)),S(a)}catch(a){console.error(a),u.error("교육 데이터 로드 실패")}finally{w(!1)}},B=async()=>{w(!0);try{const a=await Ae.getAll(s.id);b(a)}catch(a){console.error(a),u.error("심방 기록 로드 실패")}finally{w(!1)}},H=async a=>{try{await he.toggleCourse(s.id,a.id,!a.isCompleted),S(O=>O.map(L=>L.id===a.id?{...L,isCompleted:!L.isCompleted}:L)),u.success(a.isCompleted?"이수 취소":"이수 완료")}catch{u.error("업데이트 실패")}},k=async a=>{try{await q.updateStatus(s.id,a),u.success(`상태: ${a}`),r()}catch{u.error("상태 변경 실패")}},i=async a=>{try{await q.update(s.id,{settlementStage:a}
1),u.success(`정착 단계: ${a}`),r()}catch{u.error("단계 변경 실패")}},P=async()=>{if(!D.visitor.trim()||!D.content.trim()){u.error("방문자와 내용을 입력하세요.");return}try{await Ae.add(s.id,D),u.success("심방 기록 추가"),Y(!1),U({visitDate:new Date().toISOString().slice(0,10),visitor:"",type:"정기심방",content:"",followUpRequired:!1}),B()}catch{u.error("심방 기록 추가 실패")}},y=async a=>{if(confirm("이 심방 기록을 삭제하시겠습니까?"))try{await Ae.delete(s.id,a),u.success("삭제 완료"),B()}catch{u.error("삭제 실패")}},Q=a=>{if(!a)return"-";const O=a.toDate?a.toDate():new Date(a);return`${O.getFullYear()}.${O.getMonth()+1}.${O.getDate()}`},Z=[{key:"info",label:"기본정보",icon:qe},{key:"education",label:"교육과정",icon:mt},{key:"visit",label:"심방기록",icon:ht},{key:"settlement",label:"정착현황",icon:ut}];return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:l,children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-2xl mx-4 shadow-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:M[0]?e.jsx("img",{src:M[0],alt:s.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-2xl text-gray-400",children:"👤"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:s.name||"(이름 없음)"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[Q(s.registeredAt)," 등록"]}),s.department&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-50 text-blue-600 text-[10px] rounded",children:s.department}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium border ${Ve[s.status||"신규"]}`,children:s.status||"신규"})]})]})]}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-gray-100 rounded-lg",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex border-b bg-gray-50",children:Z.map(a=>e.jsxs("button",{onClick:()=>j(a.key),className:`flex-1 flex items-center justify-center gap-1.5 py-3 text-sm font-medium transition-colors ${d===a.key?"text-blue-600 border-b-2 border-blue-600 bg-white":"text-gray-500 hover:text-gray-700"}`,children:[e.jsx(a.icon,{className:"w-4 h-4"}),a.label]},a.key))}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[d==="info"&&e.jsxs("div",{className:"space-y-4",children:[M.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] bg-gray-100 rounded-lg overflow-hidden",children:e.jsx("img",{src:M[o],alt:s.name,className:"w-full h-full object-contain"})}),M.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>C(a=>(a-1+M.length)%M.length),className:"absolute left-2 top-1/2 -translate-y-1/2 p-1.5 bg-black/40 hover:bg-black/60 text-white rounded-full",children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>C(a=>(a+1)%M.length),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 bg-black/40 hover:bg-black/60 text-white rounded-full",children:e.jsx(Xe,{className:"w-4 h-4"})}),e.jsxs("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 bg-black/50 text-white text-xs px-2 py-0.5 rounded-full",children:[o+1," / ",M.length]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(ge,{icon:qe,label:"이름",value:s.name||"-"}),e.jsx(ge,{icon:gt,label:"연락처",value:s.phone||"-"}),e.jsx(ge,{icon:Je,label:"등록일",value:Q(s.registeredAt)}),e.jsx(ge,{icon:pt,label:"부서",value:s.department||"-"})]}),s.welcomeMessage&&e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-500 mb-1",children:"등록 정보"}),e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-line",children:s.welcomeMessage})]}),s.mentorName&&e.jsxs("div",{className:"bg-blue-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 mb-1",children:"담당자"}),e.jsx("p",{className:"text-sm text-blue-800",children:s.mentorName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-500 mb-2",children:"상태 변경"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Et.map(a=>e.jsx("button",{onClick:()=>k(a),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-all ${s.status===a||!s.status&&a==="신규"?Ve[a]+" ring-2 ring-offset-1 ring-blue-400":"bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100"}`,children:a},a))})]})]}),d==="education"&&e.jsx("div",{className:"space-y-3",children:I?e.jsx("div",{className:"flex justify-center py-10",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):p.length===0?e.jsx("p",{className:"text-center py-10 text-gray-400",children:"교육 과정이 없습니다."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-blue-50 rounded-lg p-3 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-blue-700",children:"이수 현황"}),e.jsxs("span",{className:"text-sm font-bold text-blue-800",children:[p.filter(a=>a.isCompleted).length," / ",p.length]})]}),e.jsx("div",{className:"mt-2 bg-blue-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"h-full bg-blue-600 rounded-full transition-all",style:{width:`${p.filter(a=>a.isCompleted).length/p.length*100}%`}})})]}),p.map(a=>e.jsxs("button",{onClick:()=>H(a),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-all ${a.isCompleted?"bg-green-50 border-green-200":"bg-white border-gray-200 hover:bg-gray-50"}`,children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${a.isCompleted?"bg-green-500":"border-2 border-gray-300"}`,children:a.isCompleted&&e.jsx(be,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("span",{className:`text-sm ${a.isCompleted?"text-green-700 line-through":"text-gray-700"}`,children:a.courseName})]},a.id))]})}),d==="visit"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:()=>Y(!0),className:"w-full flex items-center justify-center gap-1.5 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-500",children:[e.jsx(bt,{className:"w-4 h-4"})," 심방 기록 추가"]}),T&&e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 space-y-3 border",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"방문일"}),e.jsx("input",{type:"date",value:D.visitDate,onChange:a=>U({...D,visitDate:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"유형"}
1),e.jsx("select",{value:D.type,onChange:a=>U({...D,type:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm",children:Dt.map(a=>e.jsx("option",{value:a,children:a},a))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"방문자"}),e.jsx("input",{value:D.visitor,onChange:a=>U({...D,visitor:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm",placeholder:"방문자 이름"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"내용"}),e.jsx("textarea",{value:D.content,onChange:a=>U({...D,content:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm",rows:3,placeholder:"심방 내용을 기록하세요"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:D.followUpRequired,onChange:a=>U({...D,followUpRequired:a.target.checked}),className:"rounded"}),e.jsx("span",{className:"text-sm text-gray-600",children:"후속 조치 필요"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>Y(!1),className:"flex-1 px-3 py-1.5 border rounded-lg text-sm hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:P,className:"flex-1 px-3 py-1.5 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700",children:"저장"})]})]}),I?e.jsx("div",{className:"flex justify-center py-10",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):x.length===0?e.jsx("p",{className:"text-center py-10 text-gray-400 text-sm",children:"심방 기록이 없습니다."}):x.map(a=>e.jsxs("div",{className:"bg-white border rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 text-[10px] rounded-full",children:a.type}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:a.visitDate})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[a.followUpRequired&&!a.followUpDone&&e.jsx("span",{className:"px-1.5 py-0.5 bg-orange-100 text-orange-600 text-[10px] rounded-full",children:"후속조치"}),e.jsx("button",{onClick:()=>y(a.id),className:"p-1 hover:bg-red-50 rounded text-red-400 hover:text-red-600",children:e.jsx(Me,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("p",{className:"text-xs text-gray-500 mb-1",children:["방문자: ",a.visitor]}),e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-line",children:a.content})]},a.id))]}),d==="settlement"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-500 mb-3",children:"정착 단계"}),e.jsx("div",{className:"space-y-2",children:Be.map((a,O)=>{const L=s.settlementStage||"1단계-첫방문",ae=Be.indexOf(L),ee=O<=ae,le=O===ae;return e.jsxs("button",{onClick:()=>i(a),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-all ${le?"bg-blue-50 border-blue-300 ring-2 ring-blue-200":ee?"bg-green-50 border-green-200":"bg-gray-50 border-gray-200 hover:bg-gray-100"}`,children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 text-xs font-bold ${ee?"bg-green-500 text-white":"bg-gray-200 text-gray-500"}`,children:ee?e.jsx(be,{className:"w-4 h-4"}):O+1}),e.jsx("span",{className:`text-sm font-medium ${le?"text-blue-700":ee?"text-green-700":"text-gray-500"}`,children:a}),le&&e.jsx("span",{className:"ml-auto text-[10px] text-blue-500 font-medium",children:"현재"})]},a)})})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 space-y-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700",children:"정착 요약"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsx("div",{className:"text-gray-500",children:"현재 상태"}),e.jsx("div",{className:"font-medium",children:s.status||"신규"}
1),e.jsx("div",{className:"text-gray-500",children:"정착 단계"}),e.jsx("div",{className:"font-medium",children:s.settlementStage||"1단계-첫방문"}),e.jsx("div",{className:"text-gray-500",children:"담당자"}),e.jsx("div",{className:"font-medium",children:s.mentorName||"미배정"}),s.promotedToMemberId&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-gray-500",children:"교적 연동"}),e.jsx("div",{className:"font-medium text-green-600",children:"완료"})]})]})]})]})]})]})})}function ge({icon:s,label:l,value:r}){return e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(s,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-gray-400",children:l}),e.jsx("p",{className:"text-sm text-gray-700",children:r})]})]})}function Ot(){const[s,l]=c.useState([]),[r,d]=c.useState([]),[j,p]=c.useState(!0),[S,x]=c.useState(!1),[b,I]=c.useState(null),[w,o]=c.useState(""),[C,T]=c.useState([]),[Y,D]=c.useState(!1);c.useEffect(()=>{U()},[]);const U=async()=>{p(!0);try{const P=(await q.getAll()).filter(y=>y.status!=="정착완료"&&y.status!=="이탈");l(P.filter(y=>!y.mentorId)),d(P.filter(y=>y.mentorId))}catch(i){console.error(i),u.error("데이터 로드 실패")}finally{p(!1)}},M=async()=>{if(!(w.trim().length<1)){D(!0);try{const i=W($(g,"members"),F("name",">=",w.trim()),F("name","<=",w.trim()+""),J("name")),P=await _(i);T(P.docs.map(y=>({id:y.id,name:y.data().name,phone:y.data().phone||y.data().mobile||""})))}catch{try{const i=W($(g,"users"),F("name",">=",w.trim()),F("name","<=",w.trim()+"")),P=await _(i);T(P.docs.map(y=>({id:y.id,name:y.data().name||y.data().displayName||"",phone:y.data().phone||""})))}catch{T([])}}finally{D(!1)}}},G=async(i,P)=>{if(b)try{await Ye.assign(b.id,i,P),u.success(`${b.name}에게 ${P} 배정 완료`),x(!1),I(null),o(""),T([]),U()}catch{u.error("배정 실패")}},B=async i=>{if(confirm(`${i.name}의 담당자 ${i.mentorName}을(를) 해제하시겠습니까?`))try{await Ye.unassign(i.id),u.success("담당자 해제 완료"),U()}catch{u.error("해제 실패")}},H=i=>{I(i),o(""),T([]),x(!0)},k=i=>{if(!i)return"-";const P=i.toDate?i.toDate():new Date(i);return`${P.getFullYear()}.${P.getMonth()+1}.${P.getDate()}`};return j?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"space-y-6",children:[s.length>0&&e.jsxs("div",{className:"bg-orange-50 border border-orange-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ge,{className:"w-5 h-5 text-orange-500"}),e.jsxs("h3",{className:"font-bold text-orange-800",children:["담당자 미배정 (",s.length,"명)"]})]}),e.jsx("div",{className:"space-y-2",children:s.map(i=>e.jsxs("div",{className:"flex items-center justify-between bg-white rounded-lg p-3 border border-orange-100",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:i.photoUrl?e.jsx("img",{src:i.photoUrl,alt:i.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-gray-400",children:"👤"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:i.name||"(이름 없음)"}),e.jsxs("p",{className:"text-xs text-gray-400",children:[k(i.registeredAt)," · ",i.department||"-"]})]})]}),e.jsxs("button",{onClick:()=>H(i),className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 text-white rounded-lg text-xs font-medium hover:bg-blue-700",children:[e.jsx(ne,{className:"w-3.5 h-3.5"})," 배정"]})]},i.id))})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx(ze,{className:"w-5 h-5 text-blue-600"})," 담당자 배정 현황 (",r.length,"명)"]}),r.length===0?e.jsx("p",{className:"text-center py-8 text-gray-400 text-sm",children:"배정된 새가족이 없습니다."}):e.jsx("div",{className:"space-y-2",children:r.map(i=>e.jsxs("div",{className:"flex items-center justify-between bg-gray-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:i.photoUrl?e.jsx("img",{src:i.photoUrl,alt:i.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-gray-400",children:"👤"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:i.name||"(이름 없음)"}),e.jsx("p",{className:"text-xs text-gray-400",children:k(i.registeredAt)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2 py-1 bg-blue-50 text-blue-700 text-xs rounded-full font-medium",children:i.mentorName}),e.jsx("button",{onClick:()=>B(i),className:"p-1 hover:bg-red-50 rounded text-red-400 hover:text-red-600",title:"담당자 해제",children:e.jsx(V,{className:"w-4 h-4"})})]})]},i.id))})]}),S&&b&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>x(!1),children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-md mx-4 shadow-2xl",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-bold text-lg",children:"담당자 배정"}),e.jsx("button",{onClick:()=>x(!1),className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:[e.jsx("span",{className:"font-semibold",children:b.name}),"에게 담당자를 배정합니다."]}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Qe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{value:w,onChange:i=>o(i.target.value),onKeyDown:i=>i.key==="Enter"&&M(),placeholder:"교인 이름 검색",className:"w-full pl-9 pr-3 py-2 border rounded-lg text-sm"})]}),e.jsx("button",{onClick:M,className:"px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700",children:"검색"})]}),Y&&e.jsx("p",{className:"text-sm text-gray-400 text-center py-3",children:"검색 중..."}),C.length>0&&e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg divide-y",children:C.map(i=>e.jsxs("button",{onClick:()=>G(i.id,i.name),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-blue-50 text-left",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:i.name}),i.phone&&e.jsx("p",{className:"text-xs text-gray-400",children:i.phone})]}),e.jsx("span",{className:"text-xs text-blue-600",children:"선택"})]},i.id))}),!Y&&w&&C.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-gray-400 mb-2",children:"검색 ê²°ê
1³¼ê°€ 없습니다."}),e.jsxs("button",{onClick:()=>G("manual_"+Date.now(),w.trim()),className:"text-sm text-blue-600 hover:underline",children:['"',w.trim(),'" 이름으로 직접 배정']})]})]})})]})}function Ft(){const[s,l]=c.useState([]),[r,d]=c.useState([]),[j,p]=c.useState(!0),[S,x]=c.useState(null);c.useEffect(()=>{b()},[]);const b=async()=>{p(!0);try{const o=await q.getAll();l(o.filter(C=>C.status==="정착완료"&&!C.promotedToMemberId)),d(o.filter(C=>C.promotedToMemberId))}catch(o){console.error(o),u.error("데이터 로드 실패")}finally{p(!1)}},I=async o=>{var C;if(confirm(`"${o.name}"을(를) 교적부에 등록하시겠습니까?`)){x(o.id);try{const T=(C=o.registeredAt)!=null&&C.toDate?o.registeredAt.toDate():o.registeredAt?new Date(o.registeredAt):new Date;await $t.promoteToMember(o.id,{name:o.name,phone:o.phone||"",department:o.department||"",registration_date:T.toISOString().slice(0,10),member_classification:"새가족",status:"활동",memo:`새가족부에서 이전 (${T.getFullYear()}년 등록)`}),u.success(`${o.name} 교적부 등록 완료`),b()}catch(T){console.error(T),u.error("교적 등록 실패")}finally{x(null)}}},w=o=>{if(!o)return"-";const C=o.toDate?o.toDate():new Date(o);return`${C.getFullYear()}.${C.getMonth()+1}.${C.getDate()}`};return j?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ft,{className:"w-5 h-5 text-blue-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-blue-800",children:"교적부 연동 안내"}),e.jsx("p",{className:"text-xs text-blue-600 mt-1",children:'"정착완료" 상태인 새가족을 교적부(members)에 등록합니다. 등록 후에도 새가족 기록은 유지됩니다.'})]})]})}),e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx($e,{className:"w-5 h-5 text-emerald-600"}),"교적 등록 대기 (",s.length,"명)"]}),s.length===0?e.jsx("p",{className:"text-center py-8 text-gray-400 text-sm",children:"정착완료 상태이면서 교적 미등록인 새가족이 없습니다."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"flex items-center justify-between bg-emerald-50 rounded-lg p-3 border border-emerald-100",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:o.photoUrl?e.jsx("img",{src:o.photoUrl,alt:o.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-lg text-gray-400",children:"👤"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:o.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xs text-gray-400",children:w(o.registeredAt)}),o.department&&e.jsxs("span",{className:"text-xs text-gray-400",children:["· ",o.department]}),o.mentorName&&e.jsxs("span",{className:"text-xs text-blue-500",children:["담당: ",o.mentorName]})]})]})]}),e.jsx("button",{onClick:()=>I(o),disabled:S===o.id,className:"flex items-center gap-1.5 px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm font-medium hover:bg-emerald-700 disabled:opacity-50",children:S===o.id?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}):e.jsxs(e.Fragment,{children:[e.jsx(jt,{className:"w-4 h-4"})," 교적 등록"]})})]},o.id))})]}),r.length>0&&e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx(be,{className:"w-5 h-5 text-green-600"}),"교적 등록 완료 (",r.length,"명)"]}),e.jsx("div",{className:"space-y-1.5",children:r.map(o=>e.jsxs("div",{className:"flex items-center justify-between bg-gray-50 rounded-lg px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"w-4 h-4 text-green-500"}),e.jsx("span",{className:"text-sm text-gray-700",children:o.name}),e.jsx("span",{className:"text-xs text-gray-400",children:w(o.registeredAt)})]}),e.jsx("span",{className:"text-[10px] text-green-600 bg-green-50 px-2 py-0.5 rounded-full",children:"등록완료"})]},o.id))})]})]})}const De=Mt,pe="newMembers",_t={신규:"bg-blue-100 text-blue-700",교육중:"bg-yellow-100 text-yellow-700",정착중:"bg-emerald-100 text-emerald-700",정착완료:"bg-green-100 text-green-700",이탈:"bg-red-100 text-red-700"};function zt(){const{user:s}=St(),[l,r]=c.useState("members"),[d,j]=c.useState([]),[p,S]=c.useState(!0),[x,b]=c.useState(""),[I,w]=c.useState(""),[o,C]=c.useState(""),[T,Y]=c.useState(()=>{const t=new Date;return`${t.getFullYear()}
1-${String(t.getMonth()+1).padStart(2,"0")}`}),[D,U]=c.useState(!1),[M,G]=c.useState(null),[B,H]=c.useState(null),[k,i]=c.useState({name:"",phone:"",department:"장년부",welcomeMessage:"",registeredAt:new Date().toISOString().slice(0,10)}),[P,y]=c.useState([]),[Q,Z]=c.useState([]),[a,O]=c.useState(!1),L=c.useRef(null),[ae,ee]=c.useState([]),[le,re]=c.useState(!1),[K,we]=c.useState({title:"",content:""}),[X,ve]=c.useState([]),[Ue,Se]=c.useState([]),[Pe,Te]=c.useState(!1),Re=c.useRef(null),[te,ce]=c.useState(null),[de,xe]=c.useState(0);c.useEffect(()=>{l==="members"&&me(),l==="welcome"&&ke()},[T,l]);const me=async()=>{S(!0);try{const[t,n]=T.split("-").map(Number),m=new Date(t,n-1,1),h=new Date(t,n,0,23,59,59),N=W($(g,pe),F("registeredAt",">=",m),F("registeredAt","<=",h),J("registeredAt","desc")),f=await _(N);j(f.docs.map(A=>({id:A.id,...A.data()})))}catch(t){console.error("새가족 로드 실패:",t),u.error("데이터 로드 실패")}finally{S(!1)}},Ze=()=>{G(null),i({name:"",phone:"",department:"장년부",welcomeMessage:"",registeredAt:new Date().toISOString().slice(0,10)}),y([]),Z([]),U(!0)},et=t=>{G(t);let n=new Date().toISOString().slice(0,10);t.registeredAt&&(n=(t.registeredAt.toDate?t.registeredAt.toDate():new Date(t.registeredAt)).toISOString().slice(0,10)),i({name:t.name||"",phone:t.phone||"",department:t.department||"장년부",welcomeMessage:t.welcomeMessage||"",registeredAt:n}),y([]);const m=q.getPhotoUrls(t);Z(m),U(!0)},tt=t=>{const n=Array.from(t.target.files||[]);n.length!==0&&(y(m=>[...m,...n]),n.forEach(m=>{const h=new FileReader;h.onload=N=>Z(f=>{var A;return[...f,(A=N.target)==null?void 0:A.result]}),h.readAsDataURL(m)}))},st=t=>{y(n=>n.filter((m,h)=>h!==t)),Z(n=>n.filter((m,h)=>h!==t))},at=async()=>{if(!k.registeredAt){u.error("등록일을 선택해주세요.");return}O(!0);try{const t=[];if(M){const m=q.getPhotoUrls(M);for(const h of Q)h.startsWith("http")&&m.includes(h)&&t.push(h)}for(const m of P){const h=je(fe,`newMembers/${Date.now()}_${m.name}`);await ye(h,m);const N=await Ne(h);t.push(N)}const n={name:k.name.trim(),phone:k.phone.trim(),department:k.department,welcomeMessage:k.welcomeMessage.trim(),registeredAt:new Date(k.registeredAt),photoUrl:t[0]||"",photoUrls:t,isPublic:!0,updatedAt:R()};M?(await z(E(g,pe,M.id),n),u.success("수정되었습니다.")):(n.createdAt=R(),n.status="신규",await se($(g,pe),n),u.success("새가족이 등록되었습니다.")),U(!1),me()}catch(t){console.error("저장 실패:",t),u.error("저장 중 오류가 발생했습니다.")}finally{O(!1)}},lt=async t=>{if(confirm(`"${t.name}" 새가족 정보를 삭제하시겠습니까?`))try{await ie(E(g,pe,t.id)),u.success("삭제되었습니다."),me()}catch{u.error("삭제 실패")}},ke=async()=>{try{const t=W($(g,"communications"),F("type","==","welcome_party"),J("timestamp","desc")),n=await _(t),m=[];n.forEach(h=>{var f;const N=h.data();((f=N.files)==null?void 0:f.length)>0&&m.push({id:h.id,content:N.content,files:N.files,authorName:N.authorName,timestamp:N.timestamp})}),ee(m)}catch(t){console.error("환영회 사진 로드 실패:",t)}},rt=()=>{we({title:`${new Date().getMonth()+1}월 새가족 환영회`,content:""}),ve([]),Se([]),re(!0)},nt=t=>{const n=Array.from(t.target.files||[]);n.length!==0&&(ve(m=>[...m,...n]),n.forEach(m=>{const h=new FileReader;h.onload=N=>Se(f=>{var A;return[...f,(A=N.target)==null?void 0:A.result]}),h.readAsDataURL(m)}))},it=t=>{ve(n=>n.filter((m,h)=>h!==t)),Se(n=>n.filter((m,h)=>h!==t))},ot=async()=>{if(!K.title.trim()){u.error("제목을 입력해주세요.");return}if(X.length===0){u.error("사진을 선택해주세요.");return}Te(!0);try{const t=[];for(let n=0;n<X.length;n++){const m=X[n],h=je(fe,`communications/welcome_${Date.now()}_${n}_${m.name}`);await ye(h,m);const N=await Ne(h);t.push({name:m.name,url:N,type:m.type||"image/jpeg"})}await se($(g,"communications"),{content:`새가족 환영회 | ${K.title.trim()}
2${K.content.trim()}`,files:t,type:"welcome_party",authorName:"관리자",authorId:(s==null?void 0:s.uid)||null,timestamp:R(),likes:[],comments:[]}),u.success(`${X.length}장의 사진이 업로드되었습니다.`),re(!1),ke()}catch(t){console.error("환영회 사진 업로드 실패:",t),u.error("업로드 ì
2¤‘ 오류가 발생했습니다.")}finally{Te(!1)}},ct=async t=>{if(confirm("이 환영회 사진을 삭제하시겠습니까?"))try{await ie(E(g,"communications",t.id)),u.success("삭제되었습니다."),ke(),(te==null?void 0:te.id)===t.id&&ce(null)}catch{u.error("삭제 실패")}},dt=t=>{if(!t)return"-";const n=t.toDate?t.toDate():new Date(t);return`${n.getFullYear()}.${n.getMonth()+1}.${n.getDate()}`},Ee=d.filter(t=>{var n;return!(x&&!((n=t.name)!=null&&n.includes(x))||I&&t.department!==I||o&&(t.status||"신규")!==o)}),xt=[{key:"members",label:"새가족 관리",icon:ne},{key:"dashboard",label:"대시보드",icon:He},{key:"welcome",label:"환영회 사진",icon:Le},{key:"mentor",label:"담당자 배정",icon:yt},{key:"promotion",label:"교적 연동",icon:$e}];return e.jsxs("div",{className:"space-y-4 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(ne,{className:"w-6 h-6 text-blue-600"})," 새가족부"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"새가족 등록, 교육, 정착 관리"})]}),l==="members"&&e.jsxs("button",{onClick:Ze,className:"inline-flex items-center gap-1.5 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium shadow-sm",children:[e.jsx(ne,{className:"w-4 h-4"})," 새가족 등록"]}),l==="welcome"&&e.jsxs("button",{onClick:rt,className:"inline-flex items-center gap-1.5 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium shadow-sm",children:[e.jsx(Ce,{className:"w-4 h-4"})," 사진 올리기"]})]}),e.jsx("div",{className:"bg-white rounded-xl border shadow-sm overflow-x-auto",children:e.jsx("div",{className:"flex min-w-max",children:xt.map(t=>e.jsxs("button",{onClick:()=>r(t.key),className:`flex items-center gap-1.5 px-5 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${l===t.key?"text-blue-600 border-blue-600 bg-blue-50/50":"text-gray-500 border-transparent hover:text-gray-700 hover:bg-gray-50"}`,children:[e.jsx(t.icon,{className:"w-4 h-4"}),t.label]},t.key))})}),l==="members"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"이번 달 새가족"}),e.jsxs("p",{className:"text-2xl font-bold text-blue-600 mt-1",children:[d.length,"명"]})]}),De.map(t=>{const n=d.filter(m=>m.department===t).length;return n>0?e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-gray-500",children:t}),e.jsxs("p",{className:"text-2xl font-bold text-gray-800 mt-1",children:[n,"명"]})]},t):null})]}),e.jsx("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"w-4 h-4 text-gray-400"}),e.jsx("input",{type:"month",value:T,onChange:t=>Y(t.target.value),className:"px-3 py-1.5 border rounded-lg text-sm"})]}),e.jsxs("div",{className:"relative flex-1 min-w-[180px]",children:[e.jsx(Qe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{value:x,onChange:t=>b(t.target.value),placeholder:"이름 검색",className:"w-full pl-9 pr-3 py-1.5 border rounded-lg text-sm"})]}),e.jsxs("select",{value:I,onChange:t=>w(t.target.value),className:"px-3 py-1.5 border rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"부서 전체"}),De.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:o,onChange:t=>C(t.target.value),className:"px-3 py-1.5 border rounded-lg text-sm",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.jsx("option",{value:"이탈",children:"이탈"})]})]})}),p?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})}):Ee.length===0?e.jsxs("div",{className:"bg-white rounded-xl border p-12 text-center shadow-sm",children:[e.jsx(ne,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-400",children:"등록된 새가족이 없습니다."})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 ga
2p-4",children:Ee.map(t=>{const n=q.getPhotoUrls(t),m=t.status||"신규";return e.jsxs("div",{className:"bg-white rounded-xl border shadow-sm overflow-hidden hover:shadow-md transition-shadow group",children:[e.jsxs("div",{className:"aspect-[3/4] bg-gray-100 flex items-center justify-center overflow-hidden relative cursor-pointer",onClick:()=>H(t),children:[n[0]?e.jsx("img",{src:n[0],alt:t.name,className:"w-full h-full object-contain"}):e.jsx("span",{className:"text-5xl text-gray-300",children:"👤"}),n.length>1&&e.jsxs("span",{className:"absolute top-2 right-2 bg-black/50 text-white text-[10px] px-1.5 py-0.5 rounded",children:["+",n.length-1]}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors flex items-center justify-center",children:e.jsx(Nt,{className:"w-6 h-6 text-white opacity-0 group-hover:opacity-80 transition-opacity"})})]}),e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"font-semibold text-gray-900 text-sm truncate",children:t.name||"(이름 없음)"}),e.jsx("span",{className:`px-1.5 py-0.5 rounded-full text-[10px] font-medium ${_t[m]}`,children:m})]}),e.jsx("div",{className:"text-xs text-gray-400 mt-0.5",children:dt(t.registeredAt)}),t.department&&e.jsx("span",{className:"inline-block mt-1 px-2 py-0.5 bg-blue-50 text-blue-700 text-[11px] rounded-full",children:t.department}),t.mentorName&&e.jsxs("div",{className:"text-[10px] text-blue-600 mt-1",children:["담당: ",t.mentorName]}),e.jsxs("div",{className:"flex gap-1.5 mt-2 pt-2 border-t",children:[e.jsxs("button",{onClick:h=>{h.stopPropagation(),et(t)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1 text-xs text-blue-600 bg-blue-50 rounded hover:bg-blue-100",children:[e.jsx(wt,{className:"w-3 h-3"})," 수정"]}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),lt(t)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1 text-xs text-red-600 bg-red-50 rounded hover:bg-red-100",children:[e.jsx(Me,{className:"w-3 h-3"})," 삭제"]})]})]})]},t.id)})})]}),l==="dashboard"&&e.jsx(Rt,{}),l==="welcome"&&e.jsx(e.Fragment,{children:ae.length===0?e.jsxs("div",{className:"bg-white rounded-xl border p-10 text-center shadow-sm",children:[e.jsx(vt,{className:"w-10 h-10 text-gray-300 mx-auto mb-2"}),e.jsx("p",{className:"text-gray-400 text-sm",children:"환영회 사진이 없습니다."})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:ae.map(t=>{var A,Ie,Oe;const n=t.files.filter(Fe=>{var _e;return Fe.type==="image"||((_e=Fe.type)==null?void 0:_e.startsWith("image/"))}),m=n[0],h=((Ie=(A=t.content)==null?void 0:A.split(`
3`)[0])==null?void 0:Ie.replace("새가족 환영회 | ",""))||"환영회",N=(Oe=t.timestamp)!=null&&Oe.toDate?t.timestamp.toDate():t.timestamp?new Date(t.timestamp):null,f=N?`${N.getFullYear()}.${N.getMonth()+1}.${N.getDate()}`:"";return e.jsxs("div",{className:"bg-white rounded-xl border shadow-sm overflow-hidden hover:shadow-md transition-shadow group",children:[e.jsxs("div",{className:"aspect-video bg-gray-100 overflow-hidden relative cursor-pointer",onClick:()=>{ce(t),xe(0)},children:[m?e.jsx("img",{src:m.url,alt:h,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}):e.jsx("div",{className:"flex items-center justify-center h-full text-3xl text-gray-300",children:"📷"}),e.jsxs("span",{className:"absolute bottom-2 right-2 bg-black/60 text-white text-xs px-2 py-0.5 rounded",children:["📷 ",n.length,"장"]})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"font-semibold text-gray-900 text-sm truncate",children:h}),e.jsx("div",{className:"text-xs text-gray-400 mt-0.5",children:f}),e.jsxs("button",{onClick:()=>ct(t),className:"mt-2 flex items-center gap-1 px-2 py-1 text-xs text-red-600 bg-red-50 rounded hover:bg-red-100 w-full justify-center",children:[e.jsx(Me,{className:"w-3 h-3"})," 삭제"]})]})]},t.id)})})}),l==="mentor"&&e.jsx(Ot,{}),l==="promotion"&&e.jsx(Ft,{}),B&&e.jsx(It,{member:B,onClose:()=>H(null),onUpdate:()=>{me(),H(null)}}),D&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>U(!1),children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-md mx-4 shadow-2xl max-h-[90vh] overflow-y-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h3",{className:"text-lg font-bold",children:M?"새가족 수정":"새가족 등록"}),e.jsx("button",{onClick:()=>U(!1),className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1.5",children:"사진 (복수 가능)"}
3),e.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:tt}),e.jsxs("button",{onClick:()=>{var t;return(t=L.current)==null?void 0:t.click()},className:"inline-flex items-center gap-1.5 px-4 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-500 w-full justify-center",children:[e.jsx(Ce,{className:"w-4 h-4"})," 클릭하여 사진 추가"]}),Q.length>0&&e.jsx("div",{className:"mt-3 grid grid-cols-4 gap-2",children:Q.map((t,n)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden border bg-gray-50",children:[e.jsx("img",{src:t,alt:`미리보기 ${n+1}`,className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>st(n),className:"absolute top-0.5 right-0.5 w-5 h-5 bg-black/60 text-white rounded-full flex items-center justify-center text-xs hover:bg-red-500",children:e.jsx(V,{className:"w-3 h-3"})}),n===0&&e.jsx("span",{className:"absolute bottom-0.5 left-0.5 bg-blue-500 text-white text-[8px] px-1 rounded",children:"대표"})]},n))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"이름"}),e.jsx("input",{value:k.name,onChange:t=>i({...k,name:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"이름"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"연락처"}),e.jsx("input",{value:k.phone,onChange:t=>i({...k,phone:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"010-0000-0000"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"등록일 *"}),e.jsx("input",{type:"date",value:k.registeredAt,onChange:t=>i({...k,registeredAt:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"소속 부서"}),e.jsx("select",{value:k.department,onChange:t=>i({...k,department:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",children:De.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"등록 정보"}),e.jsx("textarea",{value:k.welcomeMessage,onChange:t=>i({...k,welcomeMessage:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",rows:3,placeholder:"교구, 구역, 선교회 등 등록 정보를 입력하세요"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-6",children:[e.jsx("button",{onClick:()=>U(!1),className:"flex-1 px-4 py-2 border rounded-lg text-sm hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:at,disabled:a,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700 disabled:opacity-50",children:a?"저장 중...":"저장"})]})]})}),le&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>re(!1),children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-lg mx-4 shadow-2xl max-h-[90vh] overflow-y-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[e.jsx(Le,{className:"w-5 h-5 text-blue-600"})," 환영회 사진 올리기"]}),e.jsx("button",{onClick:()=>re(!1),className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"제목 *"}),e.jsx("input",{value:K.title,onChange:t=>we({...K,title:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"예: 2월 새가족 환영회"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"내용"}),e.jsx("textarea",{value:K.content,onChange:t=>we({...K,content:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",rows:2,placeholder:"환영회 내용을 간단히 적어주세요"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1.5",children:"사진 선택 (복수 가능) *"}),e.jsx("input",{ref:Re,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:nt}),e.jsxs("button",{onClick:()=>{var t;return(t=Re.current)==null?void 0:t.click()},className:"inline-flex items-center gap-1.5 px-4 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-500 
3w-full justify-center",children:[e.jsx(Ce,{className:"w-4 h-4"})," 클릭하여 사진 추가"]}),Ue.length>0&&e.jsx("div",{className:"mt-3 grid grid-cols-3 gap-2",children:Ue.map((t,n)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden border bg-gray-50",children:[e.jsx("img",{src:t,alt:`미리보기 ${n+1}`,className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>it(n),className:"absolute top-1 right-1 w-5 h-5 bg-black/60 text-white rounded-full flex items-center justify-center text-xs hover:bg-red-500",children:e.jsx(V,{className:"w-3 h-3"})})]},n))}),X.length>0&&e.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:[X.length,"장 선택됨"]})]})]}),e.jsxs("div",{className:"flex gap-2 mt-6",children:[e.jsx("button",{onClick:()=>re(!1),className:"flex-1 px-4 py-2 border rounded-lg text-sm hover:bg-gray-50",children:"취소"}),e.jsx("button",{onClick:ot,disabled:Pe,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700 disabled:opacity-50",children:Pe?"업로드 중...":`올리기 (${X.length}장)`})]})]})}),te&&(()=>{var m,h,N;const t=te.files.filter(f=>{var A;return f.type==="image"||((A=f.type)==null?void 0:A.startsWith("image/"))}),n=((h=(m=te.content)==null?void 0:m.split(`
4`)[0])==null?void 0:h.replace("새가족 환영회 | ",""))||"환영회";return e.jsxs("div",{className:"fixed inset-0 z-[60] bg-black/90 flex flex-col",onClick:()=>ce(null),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 text-white",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg",children:n}),e.jsxs("p",{className:"text-sm text-white/70",children:[de+1," / ",t.length]})]}),e.jsx("button",{onClick:()=>ce(null),className:"p-2 hover:bg-white/10 rounded-full",children:e.jsx(V,{className:"w-6 h-6"})})]}),e.jsxs("div",{className:"flex-1 flex items-center justify-center relative",onClick:f=>f.stopPropagation(),children:[t.length>1&&e.jsx("button",{onClick:()=>xe(f=>(f-1+t.length)%t.length),className:"absolute left-2 z-10 p-2 bg-white/20 hover:bg-white/30 rounded-full text-white",children:e.jsx(Ke,{className:"w-6 h-6"})}),e.jsx("img",{src:(N=t[de])==null?void 0:N.url,alt:`사진 ${de+1}`,className:"max-w-full max-h-[70vh] object-contain rounded-lg"}),t.length>1&&e.jsx("button",{onClick:()=>xe(f=>(f+1)%t.length),className:"absolute right-2 z-10 p-2 bg-white/20 hover:bg-white/30 rounded-full text-white",children:e.jsx(Xe,{className:"w-6 h-6"})})]}),t.length>1&&e.jsx("div",{className:"flex justify-center gap-2 p-4 overflow-x-auto",onClick:f=>f.stopPropagation(),children:t.map((f,A)=>e.jsx("button",{onClick:()=>xe(A),className:`w-16 h-16 rounded-lg overflow-hidden border-2 flex-shrink-0 transition-all ${A===de?"border-white scale-110":"border-transparent opacity-60 hover:opacity-100"}`,children:e.jsx("img",{src:f.url,alt:`썸네일 ${A+1}`,className:"w-full h-full object-cover"})},A))})]})})()]})}export{zt as NewMemberManagementPage};

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.