1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as d}from"./vendor-react-zNM0AU50.js";import{A as J}from"./index.esm-NBNS-BUx.js";/* empty css */import{O as q,K as Z,U as V,a7 as x,ar as ee,c as te,aa as ae,D as se,n as re,ah as le,d as ne,X as H,T as ce,Y as oe,a8 as ie}from"./vendor-ui-CW5bJ11U.js";import{H as de,q as U,l as R,w as Y,m as F,k as S,u as B,z as xe,j as ue,x as z,y as me,D as he,G as ge,E as ye}from"./vendor-firebase-Da9KY1q_.js";import{d as g,s as fe}from"./index-D1K3lVhu.js";import"./vendor-charts-08G1rM8P.js";const W="seodoon-church",C=`churches/${W}/familyPrograms`,k=`churches/${W}/familyEnrollments`,E={async getAllPrograms(){try{const t=U(R(g,C),z("sortOrder","asc"));return(await F(t)).docs.map(c=>({id:c.id,...c.data()}))}catch(t){throw console.error("íë¡ê·¸ë¨ ëª©ë¡ ì¡°í ì¤í¨:",t),t}},async getProgramsByYear(t){try{const s=U(R(g,C),Y("year","==",t),z("sortOrder","asc"));return(await F(s)).docs.map(r=>({id:r.id,...r.data()}))}catch(s){throw console.error("ì°ëë³ íë¡ê·¸ë¨ ì¡°í ì¤í¨:",s),s}},async getProgram(t){try{const s=S(g,C,t),c=await ue(s);return c.exists()?{id:c.id,...c.data()}:null}catch(s){throw console.error("íë¡ê·¸ë¨ ì¡°í ì¤í¨:",s),s}},async createProgram(t){try{const s={...t,createdAt:new Date,updatedAt:new Date};return(await xe(R(g,C),s)).id}catch(s){throw console.error("íë¡ê·¸ë¨ ìì± ì¤í¨:",s),s}},async updateProgram(t,s){try{const c=S(g,C,t);await B(c,{...s,updatedAt:new Date})}catch(c){throw console.error("íë¡ê·¸ë¨ ìì ì¤í¨:",c),c}},async updateProgramStatus(t,s){try{const c=S(g,C,t);await B(c,{status:s,updatedAt:new Date})}catch(c){throw console.error("íë¡ê·¸ë¨ ìí ë³ê²½ ì¤í¨:",c),c}},async deleteProgram(t){try{const s=de(g),c=U(R(g,k),Y("programId","==",t));(await F(c)).docs.forEach(o=>{s.delete(o.ref)}),s.delete(S(g,C,t)),await s.commit()}catch(s){throw console.error("íë¡ê·¸ë¨ ìì ì¤í¨:",s),s}}},M={async getEnrollmentsByProgram(t){try{const s=U(R(g,k),Y("programId","==",t),z("createdAt","desc"));return(await F(s)).docs.map(r=>({id:r.id,...r.data()}))}catch(s){throw console.error("ì ì² ëª©ë¡ ì¡°í ì¤í¨:",s),s}},async getAllEnrollments(){try{const t=U(R(g,k),z("createdAt","desc"));return(await F(t)).docs.map(c=>({id:c.id,...c.data()}))}catch(t){throw console.error("ì ì²´ ì ì² ì¡°í ì¤í¨:",t),t}},async confirmEnrollment(t){try{const s=S(g,k,t);await B(s,{status:"confirmed",updatedAt:new Date})}catch(s){throw console.error("ì ì² íì ì¤í¨:",s),s}},async cancelEnrollment(t){try{const s=S(g,k,t);await B(s,{status:"cancelled",updatedAt:new Date})}catch(s){throw console.error("ì ì² ì·¨ì ì¤í¨:",s),s}},async deleteEnrollment(t){try{await me(S(g,k,t))}catch(s){throw console.error("ì ì² ìì ì¤í¨:",s),s}}},be={async getOverviewStats(){try{const t=await E.getAllPrograms(),s=await M.getAllEnrollments(),c=t.map(r=>{const o=s.filter(i=>i.programId===r.id);return{programId:r.id,programName:r.name,category:r.category,totalEnrollments:o.length,confirmedEnrollments:o.filter(i=>i.status==="confirmed").length,pendingEnrollments:o.filter(i=>i.status==="pending").length}});return{totalPrograms:t.length,activePrograms:t.filter(r=>r.status==="active").length,recruitingPrograms:t.filter(r=>r.status==="recruiting").length,totalEnrollments:s.filter(r=>r.status!=="cancelled").length,confirmedEnrollments:s.filter(r=>r.status==="confirmed").length,programStats:c}}catch(t){throw console.error("íµê³ ì¡°í ì¤í¨:",t),t}}},O={baby:"ìì ìê°ì ",couple:"ë¶ë¶",family:"ê°ì¡±",senior:"ìëì´"},Q={baby:"#E8734A",couple:"#D4627A",family:"#4CAF7A",senior:"#7C6BBF"},X={recruiting:"모ì§ì¤",upcoming:"ì§íìì ",active:"ì§íì¤",closed:"ë§ê°"},G={pending:"ë기",confirmed:"íì ",cancelled:"ì·¨ì"};
1function Oe(){const[t,s]=d.useState("dashboard"),c=[{id:"dashboard",label:"ëìë³´ë",icon:Z},{id:"programs",label:"íë¡ê·¸ë¨ ê´ë¦¬",icon:q},{id:"enrollments",label:"ì ì² ê´ë¦¬",icon:V}];return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-[18px] font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(q,{className:"w-5 h-5 text-blue-600"}),"ê°ì ì¬ìë¶"]}),e.jsx("p",{className:"text-[12px] text-gray-500 mt-1",children:"ê°ì ì¬ìë¶ íë¡ê·¸ë¨ê³¼ ì ì² íí©ì ê´ë¦¬í©ëë¤"})]})}),e.jsx("div",{className:"flex gap-1 border-b border-gray-200",children:c.map(r=>e.jsxs("button",{onClick:()=>s(r.id),className:`flex items-center gap-1.5 px-4 py-2 text-[13px] font-medium border-b-2 -mb-[1px] transition-colors ${t===r.id?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[e.jsx(r.icon,{className:"w-4 h-4"}),r.label]},r.id))}),t==="dashboard"&&e.jsx(pe,{}),t==="programs"&&e.jsx(Ne,{}),t==="enrollments"&&e.jsx(we,{})]})}function pe(){const[t,s]=d.useState(null),[c,r]=d.useState(!0);d.useEffect(()=>{o()},[]);async function o(){try{r(!0);const i=await be.getOverviewStats();s(i)}catch(i){console.error("íµê³ ë¡ë ì¤í¨:",i),x.error("íµê³ë¥¼ ë¶ë¬ì¤ì§ 못íìµëë¤")}finally{r(!1)}}return c?e.jsx("div",{className:"text-center py-12 text-gray-500 text-[13px]",children:"ë¡ë© ì¤..."}):t?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx($,{label:"ì ì²´ íë¡ê·¸ë¨",value:t.totalPrograms,icon:q,color:"blue"}),e.jsx($,{label:"모ì§ì¤",value:t.recruitingPrograms,icon:ee,color:"green"}),e.jsx($,{label:"ì§íì¤",value:t.activePrograms,icon:te,color:"blue"}),e.jsx($,{label:"ì´ ì ì²ì",value:t.totalEnrollments,icon:V,color:"blue"})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-100",children:e.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:"íë¡ê·¸ë¨ë³ ì ì² íí©"})}),t.programStats.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-400 text-[13px]",children:[e.jsx(q,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),"ë±ë¡ë íë¡ê·¸ë¨ì´ ììµëë¤"]}):e.jsx("div",{className:"divide-y divide-gray-50",children:t.programStats.map(i=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:Q[i.category]}}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-medium text-gray-900",children:i.programName}),e.jsx("div",{className:"text-[11px] text-gray-500",children:O[i.category]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[12px]",children:[e.jsxs("span",{className:"text-gray-600",children:["ì ì² ",e.jsx("span",{className:"font-semibold text-gray-900",children:i.totalEnrollments})]}),e.jsxs("span",{className:"text-green-600",children:["íì ",e.jsx("span",{className:"font-semibold",children:i.confirmedEnrollments})]}),e.jsxs("span",{className:"text-orange-600",children:["ë기 ",e.jsx("span",{className:"font-semibold",children:i.pendingEnrollments})]})]})]},i.programId))})]})]}):e.jsx("div",{className:"text-center py-12 text-gray-500 text-[13px]",children:"ë°ì´í°ë¥¼ ë¶ë¬ì¬ ì ììµëë¤"})}function $({label:t,value:s,icon:c,color:r}){const o={orange:"bg-orange-50 text-orange-600",green:"bg-green-50 text-green-600",blue:"bg-blue-50 text-blue-600",purple:"bg-purple-50 text-purple-600"};return e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[12px] text-gray-500",children:t}),e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${o[r]}`,children:e.jsx(c,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"text-[24px] font-bold text-gray-900",children:s})]})}function je(t){const s=t.data;return s?e.jsxs("div",{className:"flex gap-1 items-center h-full",children:[e.jsx("button",{className:"px-2 py-1 text-[11px] bg-blue-600 text-white rounded hover:bg-blue-700",onClick:c=>{var r;c.stopPropagation(),(r=t.onEdit)==null||r.call(t,s)},title:"ìì¸í¸ì§",children:"ìì "}),e.jsx("button",{className:"px-2 py-1 text-[11px] bg-red-500 text-white rounded hover:bg-red-600",onClick:c=>{var r;c.stopPropagation(),(r=t.onDelete)==null||r.call(t,s.id,s.name)},title:"ìì ",children:"ìì "})]}):null}
1function Ne(){const[t,s]=d.useState([]),[c,r]=d.useState(!0),[o,i]=d.useState(!1),[j,N]=d.useState(null),[p,v]=d.useState("all"),y=d.useCallback(async()=>{try{r(!0);const a=await E.getAllPrograms();s(a)}catch(a){console.error("íë¡ê·¸ë¨ ë¡ë ì¤í¨:",a),x.error("íë¡ê·¸ë¨ì ë¶ë¬ì¤ì§ 못íìµëë¤")}finally{r(!1)}},[]);d.useEffect(()=>{y()},[y]);const f=p==="all"?t:t.filter(a=>a.category===p);async function P(a,m){if(confirm(`"${m}" íë¡ê·¸ë¨ì ìì íìê² ìµëê¹? 2ì°ê´ë ì ì² ë°ì´í°ë í¨ê» ìì ë©ëë¤.`))try{await E.deleteProgram(a),x.success("íë¡ê·¸ë¨ì´ ìì ëììµëë¤"),y()}catch{x.error("ìì ì ì¤í¨íìµëë¤")}}function L(){N(null),i(!0)}function I(){i(!1),N(null),y()}const A=d.useCallback(async a=>{const m=a.data,u=a.column.colId;let b=a.newValue;(u==="sortOrder"||u==="year")&&(b=b?Number(b):u==="year"?new Date().getFullYear():0);try{await E.updateProgram(m.id,{[u]:b}),x.success("ì ì¥ëììµëë¤")}catch(w){console.error("ì ì¥ ì¤í¨:",w),x.error("ì ì¥ì ì¤í¨íìµëë¤"),a.node.setDataValue(u,a.oldValue)}},[]),T=d.useCallback(a=>{N(a.data),i(!0)},[]),n=d.useMemo(()=>[{headerName:"ìì",field:"sortOrder",width:70,editable:!0,cellDataType:"number"},{headerName:"",field:"emoji",width:50,editable:!0,filter:!1,sortable:!1},{headerName:"íë¡ê·¸ë¨ëª ",field:"name",width:150,editable:!0,cellStyle:{fontWeight:"bold"}},{headerName:"ì¹´í ê³ ë¦¬",field:"category",width:100,editable:!0,cellEditor:"agSelectCellEditor",cellEditorParams:{values:["baby","couple","family","senior"]},valueFormatter:a=>O[a.value]||a.value,cellStyle:a=>({color:Q[a.value]||"#4b5563",fontWeight:500})},{headerName:"íì¤ìê°",field:"tagline",width:150,editable:!0},{headerName:"ëì",field:"target",width:100,editable:!0},{headerName:"ì¼ì ",field:"schedule",width:140,editable:!0},{headerName:"ì¥ì",field:"location",width:100,editable:!0},{headerName:"ì°¸ê°ë¹",field:"fee",width:80,editable:!0},{headerName:"ìí",field:"status",width:90,editable:!0,cellEditor:"agSelectCellEditor",cellEditorParams:{values:["recruiting","upcoming","active","closed"]},valueFormatter:a=>X[a.value]||a.value,cellStyle:a=>{const m={recruiting:{bg:"#dcfce7",color:"#16a34a"},upcoming:{bg:"#ffedd5",color:"#ea580c"},active:{bg:"#dbeafe",color:"#2563eb"},closed:{bg:"#f3f4f6",color:"#4b5563"}},u=m[a.value]||m.closed;return{backgroundColor:u.bg,color:u.color,fontWeight:500}}},{headerName:"ì°ë",field:"year",width:70,editable:!0,cellDataType:"number"},{headerName:"ì¡ì ",field:"id",width:120,editable:!1,sortable:!1,filter:!1,cellRenderer:je,cellRendererParams:{onEdit:a=>{N(a),i(!0)},onDelete:P}}],[]),l=d.useMemo(()=>({sortable:!0,filter:!0,resizable:!0,minWidth:50,editable:!1,cellStyle:{display:"flex",alignItems:"center",fontSize:"12px",lineHeight:"normal"}}),[]);return c?e.jsx("div",{className:"text-center py-12 text-gray-500 text-[13px]",children:"ë¡ë© ì¤..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("select",{value:p,onChange:a=>v(a.target.value),className:"text-[13px] border border-gray-300 rounded-lg px-3 py-1.5 bg-white",children:[e.jsx("option",{value:"all",children:"ì ì²´ ì¹´í ê³ ë¦¬"}),Object.entries(O).map(([a,m])=>e.jsx("option",{value:a,children:m},a))]}),e.jsxs("span",{className:"text-[12px] text-gray-500",children:[f.length,"ê° íë¡ê·¸ë¨"]})]}),e.jsxs("button",{onClick:L,className:"flex items-center gap-1.5 px-3 py-1.5 bg-blue-600 text-white rounded-lg text-[13px] font-medium hover:bg-blue-700 transition-colors",children:[e.jsx(ae,{className:"w-4 h-4"}),"íë¡ê·¸ë¨ ì¶ê°"]})]}),e.jsxs("div",{className:"ag-theme-alpine",style:{height:Math.max(300,Math.min(f.length*42+50,600)),width:"100%"},children:[e.jsx("style",{children:` 3 .ag-theme-alpine .ag-cell { 4 font-size: 12px !important; 5 } 6 .ag-theme-alpine .ag-header-cell-label { 7 font-size: 12px !important; 8 } 9 `}),e.jsx(J,{rowData:f,columnDefs:n,defaultColDef:l,onCellValueChanged:A,onRowDoubleClicked:T,undoRedoCellEditing:!0,undoRedoCellEditingLimit:20,animateRows:!0,rowHeight:40,enableCellTextSelection:!0,ensureDomOrder:!0,getRowId:a=>a.data.id,noRowsOverlayComponent:()=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[e.jsx(q,{className:"w-10 h-10 text-gray-300 mb-2"}),e.jsx("p",{className:"text-[13px] text-gray-500",children:"ë±ë¡ë íë¡ê·¸ë¨ì´ ììµëë¤"})]})})]}),o&&e.jsx(ve,{program:j,onClose:I})]})}function ve({program:t,onClose:s}){const c=!!t,[r,o]=d.useState({name:(t==null?void 0:t.name)||"",tagline:(t==null?void 0:t.tagline)||"",category:(t==null?void 0:t.category)||"family",catLabel:(t==null?void 0:t.catLabel)||"",emoji:(t==null?void 0:t.emoji)||"â¤ï¸",gradient:(t==null?void 0:t.gradient)||"linear-gradient(135deg, #E8734A, #D45A30)",
9imageUrl:(t==null?void 0:t.imageUrl)||"",target:(t==null?void 0:t.target)||"",schedule:(t==null?void 0:t.schedule)||"",location:(t==null?void 0:t.location)||"ìëêµí",fee:(t==null?void 0:t.fee)||"무ë£",status:(t==null?void 0:t.status)||"upcoming",description:(t==null?void 0:t.description)||"",curriculum:(t==null?void 0:t.curriculum)||[],infoCards:(t==null?void 0:t.infoCards)||[],sortOrder:(t==null?void 0:t.sortOrder)||1,year:(t==null?void 0:t.year)||new Date().getFullYear()}),[i,j]=d.useState(!1),[N,p]=d.useState(!1),[v,y]=d.useState(""),[f,P]=d.useState(!1);function L(l){o(a=>({...a,category:l,catLabel:O[l]}))}async function I(l){var u;const a=(u=l.target.files)==null?void 0:u[0];if(!a)return;const m=5*1024*1024;if(a.size>m){x.error("íì¼ í¬ê¸°ë 5MB ì´íë§ ê°ë¥í©ëë¤");return}try{p(!0);const b=a.name.split(".").pop()||"jpg",w=(t==null?void 0:t.id)||`new-${Date.now()}`,h=he(fe,`family/programs/${w}/cover.${b}`);await ge(h,a);const D=await ye(h);o(_=>({..._,imageUrl:D})),P(!1),x.success("ì´ë¯¸ì§ê° ì
ë¡ëëììµëë¤")}catch(b){console.error("ì´ë¯¸ì§ ì
ë¡ë ì¤í¨:",b),x.error("ì´ë¯¸ì§ ì
ë¡ëì ì¤í¨íìµëë¤")}finally{p(!1)}}function A(){v.trim()&&(o(l=>({...l,curriculum:[...l.curriculum,v.trim()]})),y(""))}function T(l){o(a=>({...a,curriculum:a.curriculum.filter((m,u)=>u!==l)}))}async function n(){if(!r.name.trim()){x.error("íë¡ê·¸ë¨ëª
ì ì
ë ¥í´ì£¼ì¸ì");return}try{j(!0);const l={...r,catLabel:r.catLabel||O[r.category]};c&&t?(await E.updateProgram(t.id,l),x.success("íë¡ê·¸ë¨ì´ ìì ëììµëë¤")):(await E.createProgram(l),x.success("íë¡ê·¸ë¨ì´ ì¶ê°ëììµëë¤")),s()}catch{x.error("ì ì¥ì ì¤í¨íìµëë¤")}finally{j(!1)}}return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 bg-white px-6 py-4 border-b border-gray-200 flex items-center justify-between z-10",children:[e.jsx("h2",{className:"text-[16px] font-bold text-gray-900",children:c?"íë¡ê·¸ë¨ ìì ":"ì íë¡ê·¸ë¨ ì¶ê°"}),e.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-gray-600",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"íë¡ê·¸ë¨ëª
*"}),e.jsx("input",{type:"text",value:r.name,onChange:l=>o(a=>({...a,name:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",placeholder:"íë¡ê·¸ë¨ ì´ë¦"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"íì¤ ìê°"}),e.jsx("input",{type:"text",value:r.tagline,onChange:l=>o(a=>({...a,tagline:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",placeholder:"íì¤ íë³´ 문구"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ì¹´í
ê³ ë¦¬"}),e.jsx("select",{value:r.category,onChange:l=>L(l.target.value),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",children:Object.entries(O).map(([l,a])=>e.jsx("option",{value:l,children:a},l))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ìí"}),e.jsx("select",{value:r.status,onChange:l=>o(a=>({...a,status:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",children:Object.entries(X).map(([l,a])=>e.jsx("option",{value:l,children:a},l))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ì´ëª¨ì§"}),e.jsx("input",{type:"text",value:r.emoji,onChange:l=>o(a=>({...a,emoji:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",placeholder:"â¤ï¸"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ì ë ¬ìì"}),e.jsx("input",{type:"number",value:r.sortOrder,onChange:l=>o(a=>({...a,sortOrder:Number(l.target.value)})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",min:1})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ëí ì´ë¯¸ì§"}),e.jsxs("div",{className:"flex items-center gap-3",children:[r.imageUrl&&!f?e.jsx("img",{src:r.imageUrl,alt:"ëí ì´ë¯¸ì§",className:"w-20 h-20 rounded-lg object-cover",onError:()=>P(!0)}):e.jsx("div",{className:"w-20 h-20 rounded-lg bg-gray-100 flex items-center justify-center",children:e.jsx(oe,{className:"w-6 h-6 text-gray-300"})}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:I,className:"hidden"}),e.jsx("span",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-gray-100 text-gray-700 rounded-lg text-[12px] hover:bg-gray-200 transition-colors",children:N?"ì
ë¡ë ì
9¤...":e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-3.5 h-3.5"})," ì´ë¯¸ì§ ë³ê²½"]})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ëì"}),e.jsx("input",{type:"text",value:r.target,onChange:l=>o(a=>({...a,target:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",placeholder:"ì°¸ì¬ ëì"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ì¼ì "}),e.jsx("input",{type:"text",value:r.schedule,onChange:l=>o(a=>({...a,schedule:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",placeholder:"ì: 3주 ê³¼ì , 매주 ê¸ 10ì"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ì¥ì"}),e.jsx("input",{type:"text",value:r.location,onChange:l=>o(a=>({...a,location:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",placeholder:"ì¥ì"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ì°¸ê°ë¹"}),e.jsx("input",{type:"text",value:r.fee,onChange:l=>o(a=>({...a,fee:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]",placeholder:"ë¬´ë£ / ê¸ì¡"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ì°ë"}),e.jsx("input",{type:"number",value:r.year,onChange:l=>o(a=>({...a,year:Number(l.target.value)})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px]"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ìì¸ ì¤ëª
"}),e.jsx("textarea",{value:r.description,onChange:l=>o(a=>({...a,description:l.target.value})),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-[13px] h-32 resize-none",placeholder:"íë¡ê·¸ë¨ ìê°"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-2",children:"커리íë¼"}),r.curriculum.length>0&&e.jsx("div",{className:"space-y-1 mb-2",children:r.curriculum.map((l,a)=>e.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded px-3 py-1.5",children:[e.jsxs("span",{className:"text-[12px] text-gray-500 font-mono w-5",children:[a+1,"."]}),e.jsx("span",{className:"flex-1 text-[12px] text-gray-700",children:l}),e.jsx("button",{onClick:()=>T(a),className:"text-gray-400 hover:text-red-500",children:e.jsx(H,{className:"w-3.5 h-3.5"})})]},a))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:l=>y(l.target.value),onKeyDown:l=>l.key==="Enter"&&(l.preventDefault(),A()),className:"flex-1 border border-gray-300 rounded-lg px-3 py-1.5 text-[12px]",placeholder:"커리íë¼ í목 ì
ë ¥ í Enter"}),e.jsx("button",{onClick:A,className:"px-3 py-1.5 bg-gray-100 text-gray-700 rounded-lg text-[12px] hover:bg-gray-200",children:"ì¶ê°"})]})]})]}),e.jsxs("div",{className:"sticky bottom-0 bg-white px-6 py-4 border-t border-gray-200 flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 text-[13px] text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition-colors",children:"ì·¨ì"}),e.jsx("button",{onClick:n,disabled:i,className:"px-4 py-2 text-[13px] text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:i?"ì ì¥ ì¤...":c?"ìì ":"ì¶ê°"})]})]})})}function we(){const[t,s]=d.useState([]),[c,r]=d.useState([]),[o,i]=d.useState(!0),[j,N]=d.useState("all"),[p,v]=d.useState("all"),y=d.useCallback(async()=>{try{i(!0);const[n,l]=await Promise.all([E.getAllPrograms(),M.getAllEnrollments()]);s(n),r(l)}catch(n){console.error("ë°ì´í° ë¡ë ì¤í¨:",n),x.error("ë°ì´í°ë¥¼ ë¶ë¬ì¤ì§ 못íìµëë¤")}finally{i(!1)}},[]);d.useEffect(()=>{y()},[y]);const f=c.filter(n=>!(j!=="all"&&n.programId!==j||p!=="all"&&n.status!==p));async function P(n){try{await M.confirmEnrollment(n),x.success("ì ì²ì´ íì ëììµëë¤"),y()}catch{x.error("íì ì ì¤í¨íìµëë¤")}}
9async function L(n){if(confirm("ì´ ì ì²ì ì·¨ìíìê² ìµëê¹?"))try{await M.cancelEnrollment(n),x.success("ì ì²ì´ ì·¨ìëììµëë¤"),y()}catch{x.error("ì·¨ìì ì¤í¨íìµëë¤")}}async function I(n){if(confirm("ì´ ì ì² ë°ì´í°ë¥¼ ìì í ìì íìê² ìµëê¹?"))try{await M.deleteEnrollment(n),x.success("ìì ëììµëë¤"),y()}catch{x.error("ìì ì ì¤í¨íìµëë¤")}}function A(){if(f.length===0){x.error("ë¤ì´ë¡ëí ë°ì´í°ê° ììµëë¤");return}const n=["íë¡ê·¸ë¨","ì´ë¦","ì°ë½ì²","êµì¸ì¬ë¶","ë°°ì°ì","ìë ","ì°¸ê³ ì¬í","ìí","ì ì²ì¼"],l=f.map(h=>{var _,K;const D=h.createdAt?h.createdAt instanceof Date?h.createdAt:new Date(h.createdAt.seconds*1e3):null;return[h.programName,h.name,h.phone,h.isMember?"êµì¸":"ë¹êµì¸",((_=h.familyInfo)==null?void 0:_.spouse)||"",((K=h.familyInfo)==null?void 0:K.children)||"",h.note||"",G[h.status],D?D.toLocaleDateString("ko-KR"):""]}),a=[n,...l].map(h=>h.map(D=>`"${String(D).replace(/"/g,'""')}"`).join(",")).join(` 10`),m="\uFEFF",u=new Blob([m+a],{type:"text/csv;charset=utf-8;"}),b=URL.createObjectURL(u),w=document.createElement("a");w.href=b,w.download=`ê°ì ì¬ìë¶_ì ì²íí©_${new Date().toISOString().split("T")[0]}.csv`,w.click(),URL.revokeObjectURL(b),x.success("ë¤ì´ë¡ë ìë£")}function T(n){return!n||n.length<8?n:n.replace(/(\d{3})[-]?(\d{3,4})[-]?(\d{4})/,"$1-****-$3")}return o?e.jsx("div",{className:"text-center py-12 text-gray-500 text-[13px]",children:"ë¡ë© ì¤..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:j,onChange:n=>N(n.target.value),className:"text-[13px] border border-gray-300 rounded-lg px-3 py-1.5 bg-white",children:[e.jsx("option",{value:"all",children:"ì ì²´ íë¡ê·¸ë¨"}),t.map(n=>e.jsxs("option",{value:n.id,children:[n.emoji," ",n.name]},n.id))]}),e.jsxs("select",{value:p,onChange:n=>v(n.target.value),className:"text-[13px] border border-gray-300 rounded-lg px-3 py-1.5 bg-white",children:[e.jsx("option",{value:"all",children:"ì ì²´ ìí"}),Object.entries(G).map(([n,l])=>e.jsx("option",{value:n,children:l},n))]}),e.jsxs("span",{className:"text-[12px] text-gray-500",children:[f.length,"ê±´"]})]}),e.jsxs("button",{onClick:A,className:"flex items-center gap-1.5 px-3 py-1.5 bg-green-600 text-white rounded-lg text-[13px] font-medium hover:bg-green-700 transition-colors",children:[e.jsx(se,{className:"w-4 h-4"}),"CSV ë¤ì´ë¡ë"]})]}),f.length===0?e.jsxs("div",{className:"text-center py-12 text-gray-400",children:[e.jsx(V,{className:"w-10 h-10 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-[13px]",children:"ì ì² ë´ìì´ ììµëë¤"})]}):e.jsx("div",{className:"bg-white rounded-lg border border-gray-200 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[e.jsx("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600",children:"íë¡ê·¸ë¨"}),e.jsx("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600",children:"ì´ë¦"}),e.jsx("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600",children:"ì°ë½ì²"}),e.jsx("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600",children:"êµì¸"}),e.jsx("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600",children:"ê°ì¡±ì ë³´"}),e.jsx("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600",children:"ìí"}),e.jsx("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600",children:"ì ì²ì¼"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-medium text-gray-600",children:"ê´ë¦¬"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:f.map(n=>{var m,u;const l=n.createdAt?n.createdAt instanceof Date?n.createdAt:new Date(n.createdAt.seconds*1e3):null,a={pending:"bg-yellow-100 text-yellow-700",confirmed:"bg-green-100 text-green-700",cancelled:"bg-red-100 text-red-600"};return e.jsxs("tr",{className:"hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:"text-[12px] text-gray-700",children:n.programName})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(re,{className:"w-3.5 h-3.5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-900",children:n.name})]})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(le,{className:"w-3.5 h-3.5 text-gray-400"}),e.jsx("span",{className:"text-gray-600",children:T(n.phone)})]})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded-full ${n.isMember?"bg-blue-100 text-blue-700":"bg-gray-100 text-gray-600"}
10`,children:n.isMember?"êµì¸":"ë¹êµì¸"})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"text-[12px] text-gray-600",children:[((m=n.familyInfo)==null?void 0:m.spouse)&&e.jsxs("div",{children:["ë°°ì°ì: ",n.familyInfo.spouse]}),((u=n.familyInfo)==null?void 0:u.children)&&e.jsxs("div",{children:["ìë
: ",n.familyInfo.children]})]})}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx("span",{className:`text-[11px] px-2 py-0.5 rounded-full font-medium ${a[n.status]}`,children:G[n.status]})}),e.jsx("td",{className:"px-4 py-2.5 text-[12px] text-gray-500",children:l?l.toLocaleDateString("ko-KR"):"-"}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.status==="pending"&&e.jsx("button",{onClick:()=>P(n.id),className:"p-1 text-green-600 hover:bg-green-50 rounded transition-colors",title:"íì ",children:e.jsx(ne,{className:"w-4 h-4"})}),n.status!=="cancelled"&&e.jsx("button",{onClick:()=>L(n.id),className:"p-1 text-orange-600 hover:bg-orange-50 rounded transition-colors",title:"ì·¨ì",children:e.jsx(H,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>I(n.id),className:"p-1 text-red-500 hover:bg-red-50 rounded transition-colors",title:"ìì ",children:e.jsx(ce,{className:"w-4 h-4"})})]})})]},n.id)})})]})})]})}export{Oe as FamilyProgramManagementPage};
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.