1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as o}from"./vendor-react-zNM0AU50.js";import{q,l as P,x as A,m as L,u as E,k as S,T as C,y as $,z,D as R,G as B,E as U}from"./vendor-firebase-Da9KY1q_.js";import{d as N,s as M}from"./index-D1K3lVhu.js";import{a7 as i,F as D,aa as K,g as G,A as O,aX as X,ak as H,af as I,T,a8 as J}from"./vendor-ui-CW5bJ11U.js";import"./vendor-charts-08G1rM8P.js";function ae(){const[a,h]=o.useState(!0),[n,u]=o.useState([]),[p,v]=o.useState(""),[m,w]=o.useState("all"),[s,c]=o.useState(!1),[_,g]=o.useState(null);o.useEffect(()=>{b()},[]);async function b(){try{h(!0);const t=q(P(N,"council_posts"),A("created_at","desc")),d=(await L(t)).docs.map(y=>({id:y.id,...y.data()}));u(d)}catch(t){console.error("ë¹í ê²ìí ë¡ë© ì¤í¨:",t),i.error("ê²ìê¸ì ë¶ë¬ì¬ ì ììµëë¤")}finally{h(!1)}}const r=n.filter(t=>!(p&&!t.title.toLowerCase().includes(p.toLowerCase())||m==="published"&&t.status!=="published"||m==="draft"&&t.status!=="draft")),l={total:n.length,published:n.filter(t=>t.status==="published").length,draft:n.filter(t=>t.status==="draft").length,important:n.filter(t=>t.is_important).length};async function f(t){if(confirm("ì´ ê²ìê¸ì ìì íìê² ìµëê¹?"))try{await $(S(N,"council_posts",t)),i.success("ìì ëììµëë¤"),b()}catch{i.error("ìì ì ì¤í¨íìµëë¤")}}async function j(t,x){try{const d=x==="published"?"draft":"published";await E(S(N,"council_posts",t),{status:d,updated_at:C.now()}),i.success(d==="published"?"ê²ìëììµëë¤":"ììì ì¥ëììµëë¤"),b()}catch{i.error("ìí ë³ê²½ì ì¤í¨íìµëë¤")}}return a?e.jsx("div",{className:"flex items-center justify-center h-96",children:e.jsx("div",{className:"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",{children:[e.jsxs("h1",{className:"text-[18px] font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(D,{className:"w-5 h-5 text-blue-600"}),"ë¹í ê²ìí ê´ë¦¬"]}),e.jsx("p",{className:"text-[12px] text-gray-500 mt-1",children:"ë¹íìì ê³µê°í ê³µì§ì¬íì ê´ë¦¬í©ëë¤"})]}),e.jsxs("button",{onClick:()=>{g(null),c(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors text-[13px] font-medium",children:[e.jsx(K,{className:"w-4 h-4"}),"ê²ìê¸ ìì±"]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsx(k,{label:"ì ì²´",value:l.total}),e.jsx(k,{label:"ê²ìë¨",value:l.published,color:"green"}),e.jsx(k,{label:"ììì ì¥",value:l.draft,color:"gray"}),e.jsx(k,{label:"ì¤ì",value:l.important,color:"red"})]}),e.jsx("div",{className:"bg-white border border-gray-200 rounded shadow-sm p-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ìí"}),e.jsxs("select",{value:m,onChange:t=>w(t.target.value),className:"compact-input",children:[e.jsx("option",{value:"all",children:"ì ì²´"}),e.jsx("option",{value:"published",children:"ê²ìë¨"}),e.jsx("option",{value:"draft",children:"ììì ì¥"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ê²ì"}),e.jsxs("div",{className:"relative",children:[e.jsx(G,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"ì 목 ê²ì...",value:p,onChange:t=>v(t.target.value),className:"compact-input pl-8"})]})]})]})}),e.jsx("div",{className:"bg-white border border-gray-200 rounded shadow-sm overflow-hidden",children:r.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx(D,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-[13px] text-gray-500",children:"ë±ë¡ë ê²ìê¸ì´ ììµëë¤"})]}):e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-[11px] font-bold text-gray-700 uppercase tracking-wider",children:"ìí"}),e.jsx("th",{className:"px-4 py-3 text-left text-[11px] font-bold text-gray-700 uppercase tracking-wider",children:"ì 목"}),e.jsx("th",{className:"px-4 py-3 text-left text-[11px] font-bold text-gray-700 uppercase tracking-wider",children:"ìì±ì"}),e.jsx("th",{className:"px-4 py-3 text-left text-[11px] font-bold text-gray-700 uppercase tracking-wider",children:"ìì±ì¼"}),e.jsx("th",{className:"px-4 py-3 text-right text-[11px] font-bold text-gray-700 uppercase tracking-wider",children:"ì¡ì
"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:r.map(t=>{var x,d;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[t.is_important&&e.jsx(O,{className:"w-4 h-4 text-red-500"}),e.jsx("span",{className:`text-[11px] px-2 py-0.5 rounded font-medium ${t.status==="published"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-700"}`,children:t.status==="published"?"ê²ìë¨":"ììì ì¥"})]})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-gray-900",children:t.title}),t.attachments&&t.attachments.length>0&&e.jsxs("div",{className:"text-[11px] text-gray-500 mt-1",children:["ð ",t.attachments.length,"ê° ì²¨ë¶íì¼"]})]}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("div",{className:"text-[13px] text-gray-900",children:t.author_name})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("div",{className:"text-[13px] text-gray-500",children:(d=(x=t.created_at)==null?void 0:x.toDate)==null?void 0:d.call(x).toLocaleDateString("ko-KR")})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>j(t.id,t.status),className:`p-1.5 rounded hover:bg-gray-100 transition-colors ${t.status==="published"?"text-gray-600":"text-green-600"}`,title:t.status==="published"?"ììì ì¥":"ê²ìí기",children:t.status==="published"?e.jsx(X,{className:"w-4 h-4"}):e.jsx(H,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{g(t),c(!0)},className:"p-1.5 text-blue-600 rounded hover:bg-blue-50 transition-colors",title:"ìì ",children:e.jsx(I,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>f(t.id),className:"p-1.5 text-red-600 rounded hover:bg-red-50 transition-colors",title:"ìì ",children:e.jsx(T,{className:"w-4 h-4"})})]})})]},t.id)})})]})}),s&&e.jsx(Q,{post:_,onClose:()=>{c(!1),g(null)},onSuccess:()=>{c(!1),g(null),b()}})]})}function k({label:a,value:h,color:n}){return e.jsxs("div",{className:"bg-white border border-gray-200 rounded shadow-sm p-3",children:[e.jsx("div",{className:`text-[22px] font-bold ${n==="green"?"text-green-600":n==="red"?"text-red-600":n==="gray"?"text-gray-600":"text-gray-900"}`,children:h}),e.jsx("div",{className:"text-[11px] text-gray-500",children:a})]})}function Q({post:a,onClose:h,onSuccess:n}){const u=!!a,[p,v]=o.useState(!1),[m,w]=o.useState(!1),[s,c]=o.useState({title:(a==null?void 0:a.title)||"",content:(a==null?void 0:a.content)||"",status:(a==null?void 0:a.status)||"draft",is_important:(a==null?void 0:a.is_important)||!1,attachments:(a==null?void 0:a.attachments)||[]});async function _(r){const l=r.target.files;if(!(!l||l.length===0))try{w(!0);const f=Array.from(l).map(async t=>{const d=`${Date.now()}_${t.name}`,y=R(M,`council_attachments/${d}`);await B(y,t);const F=await U(y);return{name:t.name,url:F,size:t.size}}),j=await Promise.all(f);c({...s,attachments:[...s.attachments,...j]}),i.success("íì¼ì´ ì
ë¡ëëììµëë¤")}catch(f){console.error("íì¼ ì
ë¡ë ì¤í¨:",f),i.error("íì¼ ì
ë¡ëì ì¤í¨íìµëë¤")}finally{w(!1)}}function g(r){const l=s.attachments.filter((f,j)=>j!==r);c({...s,attachments:l})}async function b(r){if(r.preventDefault(),!s.title||!s.content){i.error("ì 목과 ë´ì©ì ì
ë ¥íì¸ì");return}
1try{v(!0);const l={title:s.title,content:s.content,status:s.status,is_important:s.is_important,attachments:s.attachments,author_name:"ê´ë¦¬ì",author_id:"admin",updated_at:C.now()};u&&(a!=null&&a.id)?(await E(S(N,"council_posts",a.id),l),i.success("ê²ìê¸ì´ ìì ëììµëë¤")):(await z(P(N,"council_posts"),{...l,created_at:C.now()}),i.success("ê²ìê¸ì´ ìì±ëììµëë¤")),n()}catch(l){console.error("ì ì¥ ì¤í¨:",l),i.error(u?"ìì ì ì¤í¨íìµëë¤":"ìì±ì ì¤í¨íìµëë¤")}finally{v(!1)}}return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[e.jsx("div",{className:"p-4 border-b border-gray-200",children:e.jsx("h2",{className:"text-[16px] font-bold text-gray-900",children:u?"ê²ìê¸ ìì ":"ê²ìê¸ ìì±"})}),e.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:["ì 목 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:s.title,onChange:r=>c({...s,title:r.target.value}),className:"compact-input",placeholder:"ì: 2025ë
ë¹í ê²°ì ì¬í",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:["ë´ì© ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:s.content,onChange:r=>c({...s,content:r.target.value}),className:"compact-input",rows:10,placeholder:"ë¹í ê³µì§ ë´ì©ì ì
ë ¥íì¸ì",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"첨ë¶íì¼"}),s.attachments.length>0&&e.jsx("div",{className:"space-y-1 mb-2",children:s.attachments.map((r,l)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-[12px] text-gray-700",children:r.name}),e.jsxs("span",{className:"text-[11px] text-gray-500",children:["(",(r.size/1024).toFixed(1)," KB)"]})]}),e.jsx("button",{type:"button",onClick:()=>g(l),className:"p-1 text-red-600 hover:bg-red-50 rounded",children:e.jsx(T,{className:"w-3.5 h-3.5"})})]},l))}),e.jsxs("label",{className:"flex items-center justify-center gap-2 px-4 py-2 border-2 border-dashed border-gray-300 rounded hover:border-blue-500 cursor-pointer transition-colors",children:[e.jsx(J,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-[13px] text-gray-600",children:m?"ì
ë¡ë ì¤...":"íì¼ ì í (ì¬ë¬ ê° ê°ë¥)"}),e.jsx("input",{type:"file",accept:"*/*",multiple:!0,onChange:_,className:"hidden",disabled:m})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:s.is_important,onChange:r=>c({...s,is_important:r.target.checked}),className:"w-4 h-4"}),e.jsx("span",{className:"text-[12px] font-medium text-gray-700",children:"ì¤ì ê³µì§ (ìë¨ì [ì¤ì] íì)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-gray-700 mb-1",children:"ìí"}),e.jsxs("select",{value:s.status,onChange:r=>c({...s,status:r.target.value}),className:"compact-input",children:[e.jsx("option",{value:"draft",children:"ììì ì¥"}),e.jsx("option",{value:"published",children:"ê²ìí기"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:h,className:"flex-1 px-3 py-2 border border-gray-300 rounded hover:bg-gray-50 transition-colors text-[13px]",children:"ì·¨ì"}),e.jsx("button",{type:"submit",disabled:p||m,className:"flex-1 px-3 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors text-[13px] font-medium disabled:opacity-50",children:p?"ì²ë¦¬ ì¤...":u?"ìì ":"ìì±"})]})]})]})})}export{ae as CouncilBoardPage};
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.