import{r as d,j as t}from"./index-CpO7mTKO.js";const c="/api/admin/members",w=()=>localStorage.getItem("admin_token"),p=()=>({Authorization:`Bearer ${w()}`,"Content-Type":"application/json"});function C(){const[x,y]=d.useState({content:[],totalElements:0}),[n,i]=d.useState(0),[f,j]=d.useState(""),[a,S]=d.useState(""),[m,h]=d.useState(!1),l=async(e=n,r=a)=>{h(!0);try{const o=new URLSearchParams({page:e,size:20,...r&&{keyword:r}}),u=await fetch(`${c}?${o}`,{headers:p()});u.ok&&y(await u.json())}finally{h(!1)}};d.useEffect(()=>{l()},[n,a]);const k=e=>{e.preventDefault(),i(0),S(f)},v=async(e,r)=>{confirm(`${r?"비활성화":"활성화"}하시겠습니까?`)&&(await fetch(`${c}/${e}/status`,{method:"PATCH",headers:p(),body:JSON.stringify({active:!r})}),l())},z=async e=>{confirm("삭제하면 복구할 수 없습니다. 삭제하시겠습니까?")&&(await fetch(`${c}/${e}`,{method:"DELETE",headers:p()}),l())},g=x.content||[],b=x.totalElements||0,s=Math.ceil(b/20);return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:24},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{fontSize:20,fontWeight:700,color:"#1e293b",margin:0},children:"회원 관리"}),t.jsxs("p",{style:{fontSize:13,color:"#64748b",margin:"4px 0 0"},children:["총 ",b.toLocaleString(),"명"]})]}),t.jsxs("form",{onSubmit:k,style:{display:"flex",gap:8},children:[t.jsx("input",{value:f,onChange:e=>j(e.target.value),placeholder:"이름 / 이메일 / 소속 검색",style:{padding:"8px 14px",border:"1px solid #e2e8f0",borderRadius:8,fontSize:13,width:240,outline:"none"}}),t.jsx("button",{type:"submit",style:{padding:"8px 16px",background:"#1a5fd8",color:"#fff",border:"none",borderRadius:8,fontSize:13,cursor:"pointer"},children:"검색"})]})]}),t.jsx("div",{style:{background:"#fff",border:"1px solid #e2e8f0",borderRadius:10,overflow:"hidden"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8fafc"},children:["ID","이름","이메일","연락처","소속","가입일","상태","액션"].map(e=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:e},e))})}),t.jsx("tbody",{children:m?t.jsx("tr",{children:t.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:"로딩 중..."})}):g.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:a?"검색 결과가 없습니다.":"등록된 회원이 없습니다."})}):g.map(e=>t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsxs("td",{style:{padding:"10px 14px",color:"#94a3b8"},children:["#",e.id]}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600,color:"#1e293b"},children:e.name}),t.jsx("td",{style:{padding:"10px 14px",color:"#475569"},children:e.email}),t.jsx("td",{style:{padding:"10px 14px",color:"#64748b"},children:e.phone||"-"}),t.jsx("td",{style:{padding:"10px 14px",color:"#64748b"},children:e.company||"-"}),t.jsx("td",{style:{padding:"10px 14px",color:"#64748b",fontSize:12},children:e.createdAt?new Date(e.createdAt).toLocaleDateString("ko-KR"):"-"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:11,fontWeight:700,background:e.active?"#dcfce7":"#fee2e2",color:e.active?"#16a34a":"#dc2626"},children:e.active?"활성":"비활성"})}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>v(e.id,e.active),style:{padding:"4px 10px",fontSize:11,borderRadius:6,cursor:"pointer",background:e.active?"#fef3c7":"#dcfce7",color:e.active?"#92400e":"#166534",border:"none"},children:e.active?"비활성화":"활성화"}),t.jsx("button",{onClick:()=>z(e.id),style:{padding:"4px 10px",fontSize:11,borderRadius:6,cursor:"pointer",background:"#fef2f2",color:"#dc2626",border:"none"},children:"삭제"})]})})]},e.id))})]})}),s>1&&t.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"center",marginTop:20},children:[t.jsx("button",{onClick:()=>i(e=>Math.max(0,e-1)),disabled:n===0,style:{padding:"6px 14px",borderRadius:6,border:"1px solid #e2e8f0",background:"#fff",cursor:"pointer",fontSize:13},children:"이전"}),Array.from({length:Math.min(5,s)},(e,r)=>{const o=Math.max(0,Math.min(n-2,s-5))+r;return t.jsx("button",{onClick:()=>i(o),style:{padding:"6px 12px",borderRadius:6,fontSize:13,cursor:"pointer",border:o===n?"none":"1px solid #e2e8f0",background:o===n?"#1a5fd8":"#fff",color:o===n?"#fff":"#475569"},children:o+1},o)}),t.jsx("button",{onClick:()=>i(e=>Math.min(s-1,e+1)),disabled:n===s-1,style:{padding:"6px 14px",borderRadius:6,border:"1px solid #e2e8f0",background:"#fff",cursor:"pointer",fontSize:13},children:"다음"})]})]})}export{C as default};
