1import{j as s}from"./vendor-data-Z5doMMu-.js";import{r as n}from"./vendor-react-zNM0AU50.js";import{by as k,w as p,bH as b,a7 as c}from"./vendor-ui-CW5bJ11U.js";import{u as M}from"./index-D1K3lVhu.js";import{f as g}from"./financeCloseService-C1M9uxKC.js";import{g as R}from"./financeConstants-CXKUiVP8.js";import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";const Y=Array.from({length:12},(r,x)=>x+1);function A(r){if(!r)return"";try{return r.toLocaleDateString("ko-KR",{dateStyle:"short"})}catch{return""}}function K(){const{user:r,isRole:x}=M(),m=(r==null?void 0:r.churchId)||"seodoon-church",f=x("ìµê³ ê´ë¦¬ì","ì¬ì ë¶ì¥"),l=Number(R()),[a,y]=n.useState(String(l)),[j,N]=n.useState([]),[w,h]=n.useState(!0),[v,o]=n.useState(null),u=()=>{h(!0),g.getCloses(m,a).then(N).catch(e=>c.error(`ë§ê° íí© ì¡°í ì¤í¨: ${e.message||e}`)).finally(()=>h(!1))};n.useEffect(u,[a]);const C=e=>j.find(t=>t.month===e&&t.closed),S=async e=>{if(window.confirm(`${a}ë ${e}ìì ë§ê°íìê² ìµëê¹? 2ë§ê° íìë í´ë¹ ìì íê¸Â·ì§ì¶ ë±ë¡/ìì /ìì ê° ì íë©ëë¤.`)){o(e);try{await g.closeMonth(m,a,e,(r==null?void 0:r.uid)||"",(r==null?void 0:r.name)||""),c.success(`${e}ìì´ ë§ê°ëììµëë¤`),u()}catch(t){c.error(`ë§ê° ì¤í¨: ${t.message||t}`)}finally{o(null)}}},$=async e=>{if(window.confirm(`${a}ë ${e}ì ë§ê°ì í´ì íìê² ìµëê¹?`)){o(e);try{await g.reopenMonth(m,a,e),c.success(`${e}ì ë§ê°ì´ í´ì ëììµëë¤`),u()}catch(t){c.error(`ë§ê° í´ì ì¤í¨: ${t.message||t}`)}finally{o(null)}}};return s.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"ì ë§ê°"}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"ìë³ ì¬ì 기ë¡ì ì ê¸ëë¤. ë§ê°ë ìì íê¸Â·ì§ì¶ ë±ë¡/ìì /ìì ê° ì íë©ëë¤."})]}),s.jsx("select",{value:a,onChange:e=>y(e.target.value),className:"border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500",children:[l+1,l,l-1,l-2].map(e=>s.jsxs("option",{value:String(e),children:[e,"ë ë"]},e))})]}),!f&&s.jsxs("div",{className:"mb-4 flex items-start gap-2 bg-blue-50 border border-blue-100 text-blue-700 rounded-lg p-3 text-sm",children:[s.jsx(k,{className:"w-4 h-4 mt-0.5 shrink-0"}),s.jsx("span",{children:"ë§ê° í´ì ë ì¬ì ë¶ì¥Â·ìµê³ ê´ë¦¬ìë§ ê°ë¥í©ëë¤. ë§ê°ì ì¤ë¥ê° ìì¼ë©´ ì¬ì ë¶ì¥ìê² ìì²íì¸ì."})]}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3",children:w?s.jsx("div",{className:"col-span-full text-center text-gray-400 py-10",children:"ë¶ë¬ì¤ë ì¤..."}):Y.map(e=>{const t=C(e),i=!!t,d=v===e;return s.jsxs("div",{className:`rounded-xl border p-4 ${i?"bg-gray-50 border-gray-200":"bg-white border-gray-200"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("span",{className:"text-lg font-bold text-gray-900",children:[e,"ì"]}),i?s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-gray-600 bg-gray-200 px-2 py-0.5 rounded-full",children:[s.jsx(p,{className:"w-3 h-3"})," ë§ê°"]}):s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-full",children:[s.jsx(b,{className:"w-3 h-3"})," ì´ë¦¼"]})]}),i&&s.jsxs("p",{className:"text-[11px] text-gray-400 mb-3",children:[(t==null?void 0:t.closedByName)||(t==null?void 0:t.closedBy)," · ",A(t==null?void 0:t.closedAt)]}),i?f?s.jsxs("button",{onClick:()=>$(e),disabled:d,className:"w-full flex items-center justify-center gap-1.5 text-sm border border-gray-300 text-gray-600 hover:bg-gray-100 py-2 rounded-lg transition-colors",children:[s.jsx(b,{className:"w-3.5 h-3.5"})," ",d?"ì²ë¦¬ ì¤...":"ë§ê° í´ì "]}):s.jsx("div",{className:"w-full text-center text-xs text-gray-300 py-2",children:"ì ê¹"}):s.jsxs("button",{onClick:()=>S(e),disabled:d,className:"w-full flex items-center justify-center gap-1.5 text-sm bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 text-white py-2 rounded-lg transition-colors",children:[s.jsx(p,{className:"w-3.5 h-3.5"})," ",d?"ì²ë¦¬ ì¤...":"ë§ê°"]})]},e)})})]})}export{K as MonthClosePage,K as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.