PageSourceSearch

https://seodoon-church-admin.web.app/assets/CouncilChatPage-BEsBg1N-.js

js seodoon-church-admin.web.app collected 2026-10-03 12:36:24 UTC 6,384 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as a}from"./vendor-react-zNM0AU50.js";import{u as p}from"./index-D1K3lVhu.js";import{f as g}from"./councilService-CCqwDmOg.js";import{L as j,M as N,aa as y,T as v,aD as w,a4 as S,z as f,X as C}from"./vendor-ui-CW5bJ11U.js";import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";function I(){const{user:n}=p(),[m,l]=a.useState([]),[d,u]=a.useState(!0),[t,o]=a.useState(null),[h,x]=a.useState(!1);a.useEffect(()=>{r()},[]);async function r(){u(!0);const s=await g.getRooms();l(s),u(!1)}async function i(s){confirm("채팅방을 삭제하시겠습니까?")&&(await g.deleteRoom(s),f.success("삭제되었습니다"),(t==null?void 0:t.id)===s&&o(null),r())}return d?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(j,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl p-6 text-gray-900",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(N,{className:"w-7 h-7 text-blue-600"}),e.jsx("h1",{className:"text-2xl font-bold",children:"채팅"})]}),e.jsx("p",{className:"text-gray-500 text-sm",children:"당회원 간 실시간 소통"})]}),t?e.jsx(k,{room:t,onBack:()=>{o(null),r()}}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:()=>x(!0),className:"flex items-center gap-1.5 px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700",children:[e.jsx(y,{className:"w-4 h-4"})," 채팅방 만들기"]})}),m.length===0?e.jsx("div",{className:"bg-white rounded-xl border p-8 text-center text-gray-400",children:"채팅방이 없습니다"}):e.jsx("div",{className:"grid gap-3",children:m.map(s=>{var c;return e.jsxs("div",{className:"bg-white rounded-xl border p-4 flex items-center gap-4 hover:bg-gray-50 cursor-pointer",onClick:()=>o(s),children:[e.jsx("div",{className:"w-12 h-12 bg-blue-600 rounded-xl flex items-center justify-center text-white font-bold text-lg",children:(c=s.name)==null?void 0:c.charAt(0)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium text-gray-800",children:s.name}),s.lastMessage&&e.jsx("p",{className:"text-sm text-gray-500 truncate",children:s.lastMessage}),s.description&&!s.lastMessage&&e.jsx("p",{className:"text-sm text-gray-400",children:s.description})]}),e.jsx("button",{onClick:b=>{b.stopPropagation(),i(s.id)},className:"p-2 hover:bg-red-100 rounded-lg",children:e.jsx(v,{className:"w-4 h-4 text-red-400"})})]},s.id)})}),h&&e.jsx(M,{onClose:()=>x(!1),onSave:r})]})]})}function k({room:n,onBack:m}){const{user:l}=p(),[d,u]=a.useState([]),[t,o]=a.useState(""),[h,x]=a.useState(!1),r=a.useRef(null);a.useEffect(()=>{const s=g.subscribeMessages(n.id,c=>{u(c),setTimeout(()=>{var b;return(b=r.current)==null?void 0:b.scrollIntoView({behavior:"smooth"})},100)});return()=>s()},[n.id]);async function i(){!t.trim()||!l||(x(!0),await g.sendMessage(n.id,{content:t,senderId:l.uid,senderName:l.name}),o(""),x(!1))}return e.jsxs("div",{className:"bg-white rounded-xl border flex flex-col",style:{height:"calc(100vh - 280px)",minHeight:"400px"},children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 border-b",children:[e.jsx("button",{onClick:m,className:"p-1.5 hover:bg-gray-100 rounded-lg",children:e.jsx(w,{className:"w-5 h-5"})}),e.jsx("h2",{className:"font-bold text-gray-800",children:n.name})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:[d.length===0&&e.jsx("p",{className:"text-center text-gray-400 text-sm py-8",children:"메시지가 없습니다. 첫 메시지를 보내보세요!"}),d.map(s=>{const c=s.senderId===(l==null?void 0:l.uid);return e.jsx("div",{className:`flex ${c?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[70%] ${c?"order-1":""}`,children:[!c&&e.jsx("p",{className:"text-xs font-medium text-gray-500 mb-1",children:s.senderName}),e.jsx("div",{className:`px-3 py-2 rounded-2xl text-sm ${c?"bg-blue-600 text-white rounded-br-md":"bg-gray-100 text-gray-800 rounded-bl-md"}`,children:s.content})]})},s.id)}),e.jsx("div",{ref:r})]}),e.jsxs("div",{className:"p-4 border-t flex gap-2",children:[e.jsx("input",{value:t,onChange:s=>o(s.target.value),onKeyDown:s=>s.key==="Enter"&&!s.shiftKey&&i(),placeholder:"메시지를 입력하세요...",className:"flex-1 border rounded-xl px-4 py-2 text-sm"}),e.jsx("button",{onClick:i,disabled:h||!t.trim(),className:"p-2.5 bg-blue-600 text-white rounded-xl hover:bg-blue-700 disabled:opacity-50",children:e.jsx(S,{className:"w-4 h-4"})})]})]})}function M({onClose:n,onSave:m}){const{user:l}
1=p(),[d,u]=a.useState(""),[t,o]=a.useState(""),[h,x]=a.useState(!1);async function r(){if(!d.trim()){f.error("채팅방 이름을 입력하세요");return}x(!0);try{await g.createRoom({name:d,description:t,createdBy:l==null?void 0:l.uid}),f.success("채팅방이 생성되었습니다"),m(),n()}catch{f.error("생성 실패")}finally{x(!1)}}return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-sm",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"font-bold text-lg",children:"채팅방 만들기"}),e.jsx("button",{onClick:n,className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(C,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:"이름 *"}),e.jsx("input",{value:d,onChange:i=>u(i.target.value),className:"w-full border rounded-lg px-3 py-2 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:"설명"}),e.jsx("input",{value:t,onChange:i=>o(i.target.value),className:"w-full border rounded-lg px-3 py-2 text-sm"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t",children:[e.jsx("button",{onClick:n,className:"px-4 py-2 text-sm border rounded-lg",children:"취소"}),e.jsx("button",{onClick:r,disabled:h,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50",children:h?"생성중...":"생성"})]})]})})}export{I as CouncilChatPage,I as default};

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.