1import{j as e}from"./vendor-data-Z5doMMu-.js";import{b as Y,f as _,r as o}from"./vendor-react-zNM0AU50.js";import{u as E}from"./index-D1K3lVhu.js";import{b as v}from"./budgetRequestService-C_9tMGTu.js";import{f as N,C as P}from"./financeConstants-CXKUiVP8.js";import{z as c,_ as B,b as F,af as M,ak as z,a4 as H,T as $,ar as G,aa as U,g as K}from"./vendor-ui-CW5bJ11U.js";import{A as O}from"./index.esm-NBNS-BUx.js";/* empty css */import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";const W={draft:{label:"ì´ì",color:"text-gray-700",bgColor:"bg-gray-100"},submitted:{label:"ë¶ì¥ì¹ì¸ë기",color:"text-yellow-700",bgColor:"bg-yellow-100"},dept_approved:{label:"본íê³ì¹ì¸ë기",color:"text-blue-700",bgColor:"bg-blue-100"},approved:{label:"ì¹ì¸ìë£",color:"text-green-700",bgColor:"bg-green-100"},rejected:{label:"ë°ë ¤",color:"text-red-700",bgColor:"bg-red-100"},paid:{label:"ì§ê¸ìë£",color:"text-purple-700",bgColor:"bg-purple-100"}};function ne({embedded:J=!1}){const h=Y(),[w]=_(),{user:a}=E(),i=(a==null?void 0:a.churchId)||"seodoon-church",[y,j]=o.useState(!0),[x,C]=o.useState([]),[Q,R]=o.useState([]),[l,p]=o.useState({fiscalYear:new Date().getFullYear().toString(),departmentId:"",status:w.get("status")||""}),[u,S]=o.useState(""),g=(a==null?void 0:a.position)||"",q=g.includes("ë¶ì¥"),A=g==="본íê³"||g.includes("íê³"),I=q||A;o.useEffect(()=>{b()},[i,l.fiscalYear,l.departmentId,l.status]);const b=async()=>{try{j(!0);const t=await v.getBudgetRequests(i,{fiscalYear:l.fiscalYear,departmentId:l.departmentId||void 0,status:l.status||void 0});C(t)}catch(t){console.error("ìì° ì ì² ëª©ë¡ ë¡ë ì¤í¨:",t),c.error("ìì° ì ì² ëª©ë¡ì ë¶ë¬ì¤ëë° ì¤í¨íìµëë¤")}finally{j(!1)}},d=o.useMemo(()=>{if(!u)return x;const t=u.toLowerCase();return x.filter(s=>{var r,m,n;return((r=s.title)==null?void 0:r.toLowerCase().includes(t))||((m=s.departmentName)==null?void 0:m.toLowerCase().includes(t))||((n=s.requesterName)==null?void 0:n.toLowerCase().includes(t))})},[x,u]),k=async t=>{if(confirm("ì ë§ ìì íìê² ìµëê¹?"))try{await v.deleteBudgetRequest(i,t),c.success("ìì ëììµëë¤"),b()}catch(s){console.error("ìì ì¤í¨:",s),c.error(s.message||"ìì ì ì¤í¨íìµëë¤")}},D=async t=>{try{await v.submitBudgetRequest(i,t,(a==null?void 0:a.uid)||"",(a==null?void 0:a.name)||""),c.success("ì ì¶ëììµëë¤"),b()}catch(s){console.error("ì ì¶ ì¤í¨:",s),c.error(s.message||"ì ì¶ì ì¤í¨íìµëë¤")}},f=o.useMemo(()=>{const t=d.length,s=d.filter(n=>["submitted","dept_approved"].includes(n.status)).length,r=d.filter(n=>["approved","paid"].includes(n.status)).length,m=d.reduce((n,L)=>n+L.amount,0);return{total:t,pending:s,approved:r,totalAmount:m}},[d]),T=o.useMemo(()=>[{field:"status",headerName:"ìí",width:130,headerCheckboxSelection:!0,checkboxSelection:!0,cellRenderer:t=>{const s=W[t.value];return e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${s.bgColor} ${s.color}`,children:s.label})}},{field:"departmentName",headerName:"ë¶ì",width:120,cellRenderer:t=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3.5 h-3.5 text-gray-400"}),e.jsx("span",{children:t.value})]})},{field:"title",headerName:"ì 목",flex:1,minWidth:200,cellRenderer:t=>{var s;return e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:t.value}),((s=t.data)==null?void 0:s.budgetItemName)&&e.jsx("p",{className:"text-xs text-gray-500",children:t.data.budgetItemName})]})}},{field:"amount",headerName:"ê¸ì¡",width:130,cellRenderer:t=>e.jsxs("div",{className:"flex items-center gap-1 font-medium text-blue-600",children:[e.jsx(F,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:N(t.value)})]})},{field:"requesterName",headerName:"ì ì²ì",width:100},{field:"requestedAt",headerName:"ì ì²ì¼",width:110,cellRenderer:t=>{var r;const s=t.value||((r=t.data)==null?void 0:r.createdAt);return s?new Date(s).toLocaleDateString("ko-KR"):"-"}},{headerName:"",width:120,sortable:!1,filter:!1,cellRenderer:t=>{const s=t.data;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>h(`/finance/requests/${s.id}/edit`),className:"p-1.5 text-blue-600 hover:bg-blue-50 rounded",title:["draft","rejected"].includes(s.status)?"ìì ":"보기",children:["draft","rejected"].includes(s.status)?e.jsx(M,{className:"w-4 h-4"}):e.jsx(z,{className:"w-4 h-4"})}),s.status==="draft"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>D(s.id),className:"p-1.5 text-green-600 hover:bg-green-50 rounded",title:"ì ì¶",children:e.jsx(H,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>k(s.id),className:"p-1.5 text-red-600 hover:bg-red-50 rounded",title:"ìì ",children:e.jsx($,{className:"w-4 h-4"})})]})]})}}],[]);return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"ìì° ì ì²"}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["ì´ ",f.total,"ê±´ | ì¹ì¸ë기 ",f.pending,"ê±´ | í©ê³ ",N(f.totalAmount)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[I&&e.jsxs("button",{onClick:()=>h("/finance/requests/approval"),className:"flex items-center gap-2 px-4 py-2 border border-blue-600 text-blue-600 rounded-lg hover:bg-blue-50",children:[e.jsx(G,{className:"w-4 h-4"}),"ì¹ì¸ ê´ë¦¬"]}),e.jsxs("button",{onClick:()=>h("/finance/requests/new"),className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:[e.jsx(U,{className:"w-4 h-4"}),"ìì° ì ì²"]})]})]}),e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-4 mb-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"ì 목, ë¶ì, ì ì²ì ê²ì...",value:u,onChange:t=>S(t.target.value),className:"w-full pl-9 pr-4 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsx("select",{value:l.fiscalYear,onChange:t=>p(s=>({...s,fiscalYear:t.target.value})),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:[...Array(3)].map((t,s)=>{const r=new Date().getFullYear()-s;return e.jsxs("option",{value:r.toString(),children:[r,"ë
"]},r)})}),e.jsxs("select",{value:l.departmentId,onChange:t=>p(s=>({...s,departmentId:t.target.value})),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"ì ì²´ ë¶ì"}),P.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:l.status,onChange:t=>p(s=>({...s,status:t.target.value})),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"ì ì²´ ìí"}),e.jsx("option",{value:"draft",children:"ì´ì"}),e.jsx("option",{value:"submitted",children:"ë¶ì¥ì¹ì¸ë기"}),e.jsx("option",{value:"dept_approved",children:"본íê³ì¹ì¸ë기"}),e.jsx("option",{value:"approved",children:"ì¹ì¸ìë£"}),e.jsx("option",{value:"rejected",children:"ë°ë ¤"}),e.jsx("option",{value:"paid",children:"ì§ê¸ìë£"})]})]})}),e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100",children:e.jsx("div",{className:"ag-theme-alpine",style:{height:"calc(100vh - 320px)",width:"100%"},children:e.jsx(O,{rowData:d,columnDefs:T,defaultColDef:{sortable:!0,filter:!0,resizable:!0},rowSelection:"multiple",onSelectionChanged:t=>R(t.api.getSelectedRows()),animateRows:!0,loading:y,overlayNoRowsTemplate:"<span class='text-gray-400'>ìì° ì ì² ë´ìì´ ììµëë¤</span>"})})})]})}export{ne as BudgetRequestListPage};
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.