PageSourceSearch

https://seodoon-church-admin.web.app/assets/OfferingFormPage-CiV4YmRm.js

js seodoon-church-admin.web.app collected 2026-10-03 12:37:08 UTC 7,999 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-data-Z5doMMu-.js";import{b as C,h as S,r as o}from"./vendor-react-zNM0AU50.js";import{u as M}from"./index-D1K3lVhu.js";import{o as f}from"./offeringService-Cuo8E004.js";import{f as T}from"./financeCloseService-C1M9uxKC.js";import{g as I,r as b,P as O}from"./financeConstants-CXKUiVP8.js";import{f as A}from"./financeSettingsService-Gao7wv_9.js";import{M as k}from"./MemberSearchInput-B4_Iy3N2.js";import{z as n,aD as D,c as E,N as F,n as Y,F as P,b as _,bD as q,ae as z}from"./vendor-ui-CW5bJ11U.js";import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";function W({mode:i}){const m=C(),{id:d}=S(),{user:u}=M(),l=(u==null?void 0:u.churchId)||"seodoon-church",[y,p]=o.useState(!1),[g,x]=o.useState(!1),[r,t]=o.useState({date:new Date().toISOString().split("T")[0],fiscalYear:I(),amount:0,type:"tithe",typeName:"십일조",isAnonymous:!1,paymentMethod:"cash",status:"pending",memo:""}),[h,v]=o.useState(()=>b());o.useEffect(()=>{A.getSettings(l).then(s=>v(b(s.offeringTypes))).catch(()=>{})},[l]),o.useEffect(()=>{i==="edit"&&d&&j()},[i,d]);const j=async()=>{try{p(!0);const s=await f.getOffering(l,d);s&&t({date:s.date,fiscalYear:s.fiscalYear,amount:s.amount,type:s.type,typeName:s.typeName,memberId:s.memberId,memberName:s.memberName,isAnonymous:s.isAnonymous,paymentMethod:s.paymentMethod,serviceType:s.serviceType,status:s.status,memo:s.memo})}catch(s){console.error("헌금 로드 실패:",s),n.error("헌금 정보를 불러오는데 실패했습니다")}finally{p(!1)}},N=s=>{const a=h.find(c=>c.value===s);t(c=>({...c,type:s,typeName:(a==null?void 0:a.label)||s}))},w=async s=>{if(s.preventDefault(),!r.amount||r.amount<=0){n.error("금액을 입력해주세요");return}if(!r.isAnonymous&&!r.memberId){n.error("헌금자를 선택해주세요");return}try{if(x(!0),await T.isMonthClosed(l,r.date)){n.error("마감된 월입니다. 해당 월의 헌금은 등록/수정할 수 없습니다."),x(!1);return}i==="create"?(await f.createOffering(l,r),n.success("헌금이 등록되었습니다")):(await f.updateOffering(l,d,r),n.success("헌금이 수정되었습니다")),m("/finance/offerings")}catch(a){console.error("헌금 저장 실패:",a),n.error("헌금 저장에 실패했습니다")}finally{x(!1)}};return y?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}):e.jsxs("div",{className:"p-6 max-w-2xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("button",{onClick:()=>m("/finance/offerings"),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:e.jsx(D,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:i==="create"?"헌금 등록":"헌금 수정"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:i==="create"?"새로운 헌금을 등록합니다":"헌금 정보를 수정합니다"})]})]}),e.jsxs("form",{onSubmit:w,className:"bg-white rounded-xl shadow-sm border border-gray-100 p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 mb-2",children:[e.jsx(E,{className:"w-4 h-4"}),"날짜 *"]}),e.jsx("input",{type:"date",value:r.date,onChange:s=>t(a=>({...a,date:s.target.value})),className:"w-full px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsx("div",{children:e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.isAnonymous,onChange:s=>t(a=>({...a,isAnonymous:s.target.checked,memberId:s.target.checked?void 0:a.memberId,memberName:s.target.checked?void 0:a.memberName})),className:"w-4 h-4 text-blue-600 rounded focus:ring-blue-500"}),e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-700",children:[e.jsx(F,{className:"w-4 h-4"}),"익명 헌금"]})]})}),!r.isAnonymous&&e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 mb-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"헌금자 *"]}),e.jsx(k,{value:r.memberId&&r.memberName?{id:r.memberId,name:r.memberName}:null,onChange:s=>t(a=>({...a,memberId:s==null?void 0:s.id,memberName:s==null?void 0:s.name})),placeholder:"교인 이름 검색..."})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 mb-2",children:[e.jsx(P,{className:"w-4 h-4"}),"헌금 유형 *"]}
1),e.jsx("select",{value:r.type,onChange:s=>N(s.target.value),className:"w-full px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0,children:h.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 mb-2",children:[e.jsx(_,{className:"w-4 h-4"}),"금액 *"]}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400",children:"₩"}),e.jsx("input",{type:"number",placeholder:"0",value:r.amount||"",onChange:s=>t(a=>({...a,amount:Number(s.target.value)})),className:"w-full pl-8 pr-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",min:"0",step:"1000",required:!0})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 mb-2",children:[e.jsx(q,{className:"w-4 h-4"}),"결제 방법 *"]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:O.map(s=>e.jsxs("label",{className:`flex items-center justify-center gap-2 px-4 py-2.5 border rounded-lg cursor-pointer transition-colors ${r.paymentMethod===s.value?"border-blue-500 bg-blue-50 text-blue-700":"border-gray-200 hover:border-gray-300"}`,children:[e.jsx("input",{type:"radio",name:"paymentMethod",value:s.value,checked:r.paymentMethod===s.value,onChange:a=>t(c=>({...c,paymentMethod:a.target.value})),className:"sr-only"}),e.jsx("span",{className:"text-sm",children:s.label})]},s.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 mb-2",children:"예배 유형"}),e.jsxs("select",{value:r.serviceType||"",onChange:s=>t(a=>({...a,serviceType:s.target.value||void 0})),className:"w-full px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"선택 안함"}),e.jsx("option",{value:"sunday_1",children:"주일 1부"}),e.jsx("option",{value:"sunday_2",children:"주일 2부"}),e.jsx("option",{value:"sunday_3",children:"주일 3부"}),e.jsx("option",{value:"wednesday",children:"수요예배"}),e.jsx("option",{value:"friday",children:"금요예배"}),e.jsx("option",{value:"dawn",children:"새벽예배"}),e.jsx("option",{value:"special",children:"특별예배"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"메모"}),e.jsx("textarea",{placeholder:"메모를 입력하세요",value:r.memo||"",onChange:s=>t(a=>({...a,memo:s.target.value})),className:"w-full px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t",children:[e.jsx("button",{type:"button",onClick:()=>m("/finance/offerings"),className:"px-4 py-2.5 border border-gray-200 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors",children:"취소"}),e.jsxs("button",{type:"submit",disabled:g,className:"flex items-center gap-2 px-4 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:[e.jsx(z,{className:"w-4 h-4"}),g?"저장 중...":"저장"]})]})]})]})}export{W as OfferingFormPage};

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.