PageSourceSearch

https://seodoon-church-admin.web.app/assets/CounselingManagementPage-LfS7N3Y8.js

js seodoon-church-admin.web.app collected 2026-10-03 12:35:43 UTC 14,574 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as l}from"./vendor-react-zNM0AU50.js";import{q as M,x as B,l as E,I,T as K,u as U,k as S,y as A}from"./vendor-firebase-Da9KY1q_.js";import{d as w}from"./index-D1K3lVhu.js";import{M as P,i as D,A as R,c as O,ar as o,ab as X,n as G,ah as H,ax as v,T as J,z as m}from"./vendor-ui-CW5bJ11U.js";import"./vendor-charts-08G1rM8P.js";function ee(){var C;const[c,T]=l.useState([]),[$,k]=l.useState(!0),[d,h]=l.useState("all"),[t,i]=l.useState(null),[g,u]=l.useState(""),[j,y]=l.useState(""),[f,N]=l.useState("");l.useEffect(()=>{const s=M(E(w,"pastoral_counseling"),B("created_at","desc")),a=I(s,r=>{const p=r.docs.map(x=>({id:x.id,...x.data()}));T(p),k(!1)},r=>{console.error("상담 요청 조회 실패:",r),m.error("상담 요청을 불러오는데 실패했습니다."),k(!1)});return()=>a()},[]);const _=c.filter(s=>d==="pending"?s.status==="pending":d==="urgent"?s.request_type==="urgent"&&s.status==="pending":!0),n={total:c.length,pending:c.filter(s=>s.status==="pending").length,urgent:c.filter(s=>s.request_type==="urgent"&&s.status==="pending").length,scheduled:c.filter(s=>s.status==="scheduled").length,completed:c.filter(s=>s.status==="completed").length},b=async(s,a)=>{try{const r={status:a};a==="scheduled"&&f&&(r.scheduled_at=K.fromDate(new Date(f))),g.trim()&&(r.pastor_response=g.trim()),j.trim()&&(r.pastor_notes=j.trim()),await U(S(w,"pastoral_counseling",s),r),m.success("상태가 업데이트되었습니다."),i(null),u(""),y(""),N("")}catch(r){console.error("상태 업데이트 실패:",r),m.error("상태 업데이트에 실패했습니다.")}},z=async s=>{if(window.confirm("이 상담 요청을 삭제하시겠습니까? 이 작업은 취소할 수 없습니다."))try{await A(S(w,"pastoral_counseling",s)),m.success("상담 요청이 삭제되었습니다."),i(null)}catch(a){console.error("상담 요청 삭제 실패:",a),m.error("상담 요청 삭제에 실패했습니다.")}},F=s=>{i(s),u(s.pastor_response||""),y(s.pastor_notes||""),N(s.scheduled_at?new Date(s.scheduled_at.toDate()).toISOString().split("T")[0]:"")},L=s=>{const a={pending:{text:"대기 중",class:"bg-yellow-100 text-yellow-800",icon:D},scheduled:{text:"예약 확정",class:"bg-green-100 text-green-800",icon:o},completed:{text:"완료",class:"bg-gray-100 text-gray-800",icon:o},cancelled:{text:"취소됨",class:"bg-red-100 text-red-800",icon:v}};return a[s]||a.pending};return $?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-gray-500",children:"로딩 중..."})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"목회 상담 관리"}),e.jsx("p",{className:"text-gray-600 mt-1",children:"성도들의 상담 요청을 확인하고 관리합니다"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsx("div",{className:"bg-white rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600",children:"전체 요청"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:n.total})]}),e.jsx(P,{className:"w-8 h-8 text-blue-500"})]})}),e.jsx("div",{className:"bg-white rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600",children:"대기 중"}),e.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:n.pending})]}),e.jsx(D,{className:"w-8 h-8 text-yellow-500"})]})}),e.jsx("div",{className:"bg-white rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600",children:"긴급 상담"}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:n.urgent})]}),e.jsx(R,{className:"w-8 h-8 text-red-500"})]})}),e.jsx("div",{className:"bg-white rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600",children:"예약 확정"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:n.scheduled})]}),e.jsx(O,{className:"w-8 h-8 text-green-500"})]})}),e.jsx("div",{className:"bg-white rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600",children:"완료"}),e.jsx("p",{className:"text-2xl font-bold text-gray-600",children:n.completed})]}),e.jsx(o,{className:"w-8 h-8 text-gray-500"})]})})]}),e.jsx("div",{className:"bg-white rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"w-5 h-5 text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"필터:"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>h("all"),className:`px-3 py-1 rounded-lg text-sm font-medium transition-colors ${d==="all"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:"전체"}),e.jsxs("button",{onClick:()=>h("pending"),className:`px-3 py-1 rounded-lg text-sm font-medium transition-colors ${d==="pending"?"bg-yellow-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:["대기 중 (",n.pending,")"]}),e.jsxs("button",{onClick:()=>h("urgent"),className:`px-3 py-1 rounded-lg text-sm font-medium transition-colors ${d==="urgent"?"bg-red-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:["긴급 (",n.urgent,")"]})]})]})}),e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:_.length===0?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"상담 요청이 없습니다."}):e.jsx("div",{className:"overflow-x-auto",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-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"상태"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"유형"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"요청자"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"연락처"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"제목"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"내용"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"희망 날짜"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"희망 시간"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"요청 일시"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:"예약 확정일"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:_.map(s=>{var x;const a=L(s.status),r=a.icon,p=s.request_type==="urgent";return e.jsxs("tr",{className:`hover:bg-gray-50 transition-colors cursor-pointer ${p&&s.status==="pending"?"bg-red-50":""}`,onClick:()=>F(s),children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium ${a.class}`,children:[e.jsx(r,{className:"w-3 h-3"}),a.text]})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:p?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-red-100 text-red-800 text-xs font-medium rounded-full",children:[e.jsx(R,{className:"w-3 h-3"}),"긴급"]}):e.jsx("span",{className:"text-sm text-gray-600",children:"일반"})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-900",children:[e.jsx(G,{className:"w-4 h-4 text-gray-400"}),s.user_name]})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:s.phone?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-600",children:[e.jsx(H,{className:"w-4 h-4 text-gray-400"}),s.phone]}):e.jsx("span",{className:"text-sm text-gray-400",children:"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"text-sm font-medium text-gray-900 max-w-xs truncate",children:s.subject})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"text-sm text-gray-600 max-w-md truncate",children:s.message})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-600",children:s.preferred_date||"-"}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-600",children:s.preferred_time||"-"}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-600",children:(x=s.created_at)==null?void 0:x.toDate().toLocaleDateString("ko-KR")}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-600",children:s.scheduled_at?s.scheduled_at.toDate().toLocaleDateString("ko-KR"):"-"})]},s.id)})})]})})}),t&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:"상담 요청 상세"}),e.jsx("button",{onClick:()=>i(null),className:"text-gray-400 hover:text-gray-600",children:e.jsx(v,{className:"w-6 h-6"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-gray-50 rounded-lg p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600",children:"요청자:"}),e.jsx("span",{className:"ml-2 font-medium",children:t.user_name})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600",children:"연락처:"}),e.jsx("span",{className:"ml-2 font-medium",children:t.phone||"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600",children:"요청 유형:"}),e.jsx("span",{className:`ml-2 font-medium ${t.request_type==="urgent"?"text-red-600":"text-blue-600"}`,children:t.request_type==="urgent"?"긴급 상담":"일반 상담"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600",children:"요청 일시:"}),e.jsx("span",{className:"ml-2 font-medium",children:(C=t.created_at)==null?void 0:C.toDate().toLocaleStr
1ing("ko-KR")})]}),t.preferred_date&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600",children:"희망 날짜:"}),e.jsx("span",{className:"ml-2 font-medium",children:t.preferred_date})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-600",children:"희망 시간:"}),e.jsx("span",{className:"ml-2 font-medium",children:t.preferred_time||"-"})]})]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"제목"}),e.jsx("div",{className:"bg-gray-50 rounded p-3 text-gray-900",children:t.subject})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"상담 내용"}),e.jsx("div",{className:"bg-gray-50 rounded p-3 text-gray-900 whitespace-pre-wrap",children:t.message})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"목사님 답변"}),e.jsx("textarea",{value:g,onChange:s=>u(s.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",rows:4,placeholder:"성도에게 전달할 답변을 입력하세요..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"목사님 노트 (비공개)"}),e.jsx("textarea",{value:j,onChange:s=>y(s.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",rows:3,placeholder:"개인 기록용 메모..."})]}),t.status!=="completed"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"예약 확정 날짜"}),e.jsx("input",{type:"date",value:f,onChange:s=>N(s.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),e.jsxs("div",{className:"flex flex-col gap-3 pt-4",children:[e.jsxs("div",{className:"flex gap-2",children:[t.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>b(t.id,"scheduled"),className:"flex-1 px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 flex items-center justify-center gap-2",children:[e.jsx(o,{className:"w-4 h-4"}),"예약 확정"]}),e.jsxs("button",{onClick:()=>b(t.id,"cancelled"),className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 flex items-center justify-center gap-2",children:[e.jsx(v,{className:"w-4 h-4"}),"취소"]})]}),t.status==="scheduled"&&e.jsxs("button",{onClick:()=>b(t.id,"completed"),className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 flex items-center justify-center gap-2",children:[e.jsx(o,{className:"w-4 h-4"}),"상담 완료"]}),e.jsx("button",{onClick:()=>i(null),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50",children:"닫기"})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("button",{onClick:()=>z(t.id),className:"w-full px-4 py-2 bg-gray-100 text-red-600 rounded-lg hover:bg-red-50 border border-red-200 flex items-center justify-center gap-2 transition-colors",children:[e.jsx(J,{className:"w-4 h-4"}),"상담 요청 삭제"]})})]})]})]})})})]})}export{ee as CounselingManagementPage};

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.