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.