import{c as f,r as c,U as d,S as b,F as $,W as S,C as U,d as D,j as e,e as E,f as x,g as j}from"./index-HUEYA8gO.js";import{T as h,a as R}from"./trending-up-CKoyN7JV.js";import{C as M}from"./circle-alert-DLnj9LnO.js";import{C as L}from"./clock-DgYiYlPW.js";/**
 * @license lucide-react v0.545.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const A=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],N=f("message-square",A);/**
 * @license lucide-react v0.545.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const I=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],v=f("refresh-cw",I);function F({setAdminTab:n}){const[l,w]=c.useState({users:0,activeUsers:0,plans:0,kyc:0,deposits:0,withdrawals:0,tickets:0,revenue:0}),[m,k]=c.useState([]),[y,p]=c.useState(!0),[u,g]=c.useState(null),o=async()=>{p(!0),g(null);try{const[s,i]=await Promise.all([fetch(j("/admin_stats.php"),{credentials:"include"}),fetch(j("/admin_recent.php"),{credentials:"include"})]);if(s.ok){const r=await s.json();if(r.success){const t=r.data||r;w({users:t.totalUsers||t.total_users||t.users||0,activeUsers:t.activeUsers||t.active_users||0,plans:t.activePlans||t.plans_active||t.plans||0,kyc:t.pendingKyc||t.pending_kyc||t.kyc_pending||0,deposits:t.recentDeposits||t.recent_deposits||0,withdrawals:t.recentWithdrawals||t.recent_withdrawals||0,tickets:t.openTickets||t.tickets_open||t.open_tickets||0,revenue:t.revenue||t.total_revenue||0})}}if(i.ok){const r=await i.json();if(r.success&&r.data){const t=[];r.data.registrations&&r.data.registrations.forEach(a=>{t.push({type:"user",text:`New user: ${a.username}`,time:a.created_at,icon:e.jsx(d,{className:"w-4 h-4"})})}),r.data.deposits&&r.data.deposits.forEach(a=>{t.push({type:"deposit",text:`Deposit: ${a.username} - $${a.amount}`,time:a.created_at,status:a.status,icon:e.jsx(h,{className:"w-4 h-4"})})}),r.data.withdrawals&&r.data.withdrawals.forEach(a=>{t.push({type:"withdrawal",text:`Withdrawal: ${a.username} - $${a.amount}`,time:a.created_at,status:a.status,icon:e.jsx(R,{className:"w-4 h-4"})})}),k(t.sort((a,_)=>new Date(_.time)-new Date(a.time)).slice(0,10))}}}catch(s){console.error("Error fetching dashboard data:",s),g("Failed to load dashboard data")}finally{p(!1)}};c.useEffect(()=>{o()},[]);const C=[{icon:d,label:"Users",tab:"users",color:"blue",count:l.users},{icon:b,label:"KYC",tab:"kyc",color:"purple",count:l.kyc,urgent:l.kyc>0},{icon:$,label:"Transactions",tab:"transactions",color:"green"},{icon:S,label:"Balances",tab:"balances",color:"yellow"},{icon:h,label:"Investments",tab:"investment_management",color:"indigo"},{icon:U,label:"Methods",tab:"methods",color:"cyan"},{icon:N,label:"Tickets",tab:"tickets",color:"orange",count:l.tickets,urgent:l.tickets>0},{icon:D,label:"Settings",tab:"settings",color:"gray"}];return y?e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-12 h-12 text-blue-500 animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-slate-400",children:"Loading dashboard..."})]})}):u?e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(M,{className:"w-12 h-12 text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-red-400 mb-4",children:u}),e.jsx("button",{onClick:o,className:"px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors",children:"Retry"})]})}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white",children:"Admin Dashboard"}),e.jsx("p",{className:"text-slate-400 mt-1",children:"Welcome back! Here's what's happening today."})]}),e.jsxs("button",{onClick:o,className:"flex items-center gap-2 px-4 py-2 bg-slate-700 hover:bg-slate-600 text-white rounded-lg transition-colors",children:[e.jsx(v,{className:"w-4 h-4"}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx("button",{onClick:()=>n("users"),className:"bg-slate-800 border border-slate-700 rounded-lg p-6 hover:bg-slate-700 hover:border-blue-500/50 transition-all cursor-pointer text-left group",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-400 text-sm",children:"Total Users"}),e.jsx("p",{className:"text-3xl font-bold text-white mt-1 group-hover:text-blue-400 transition-colors",children:l.users}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:[l.activeUsers," active"]})]}),e.jsx("div",{className:"p-3 bg-blue-500/10 rounded-lg group-hover:bg-blue-500/20 transition-colors",children:e.jsx(d,{className:"w-8 h-8 text-blue-400"})})]})}),e.jsx("button",{onClick:()=>n("kyc"),className:"bg-slate-800 border border-slate-700 rounded-lg p-6 hover:bg-slate-700 hover:border-purple-500/50 transition-all cursor-pointer text-left group",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-400 text-sm",children:"Pending KYC"}),e.jsx("p",{className:"text-3xl font-bold text-white mt-1 group-hover:text-purple-400 transition-colors",children:l.kyc}),l.kyc>0&&e.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:"Needs attention"})]}),e.jsx("div",{className:"p-3 bg-purple-500/10 rounded-lg group-hover:bg-purple-500/20 transition-colors",children:e.jsx(b,{className:"w-8 h-8 text-purple-400"})})]})}),e.jsx("button",{onClick:()=>n("tickets"),className:"bg-slate-800 border border-slate-700 rounded-lg p-6 hover:bg-slate-700 hover:border-orange-500/50 transition-all cursor-pointer text-left group",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-400 text-sm",children:"Open Tickets"}),e.jsx("p",{className:"text-3xl font-bold text-white mt-1 group-hover:text-orange-400 transition-colors",children:l.tickets}),l.tickets>0&&e.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Needs response"})]}),e.jsx("div",{className:"p-3 bg-orange-500/10 rounded-lg group-hover:bg-orange-500/20 transition-colors",children:e.jsx(N,{className:"w-8 h-8 text-orange-400"})})]})}),e.jsx("button",{onClick:()=>n("investment_management"),className:"bg-slate-800 border border-slate-700 rounded-lg p-6 hover:bg-slate-700 hover:border-green-500/50 transition-all cursor-pointer text-left group",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-400 text-sm",children:"Active Plans"}),e.jsx("p",{className:"text-3xl font-bold text-white mt-1 group-hover:text-green-400 transition-colors",children:l.plans}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Investment plans"})]}),e.jsx("div",{className:"p-3 bg-green-500/10 rounded-lg group-hover:bg-green-500/20 transition-colors",children:e.jsx(h,{className:"w-8 h-8 text-green-400"})})]})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Quick Access"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:C.map(s=>{const i=s.icon;return e.jsxs("button",{onClick:()=>n(s.tab),className:`relative bg-slate-800 border border-slate-700 rounded-lg p-4 hover:bg-slate-700 transition-colors group ${s.urgent?"ring-2 ring-yellow-500/50 animate-pulse":""}`,children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`p-3 bg-${s.color}-500/10 rounded-lg mb-3 group-hover:bg-${s.color}-500/20 transition-colors`,children:e.jsx(i,{className:`w-6 h-6 text-${s.color}-400`})}),e.jsx("p",{className:"text-white font-medium text-sm",children:s.label}),s.count!==void 0&&e.jsxs("p",{className:`text-xs mt-1 ${s.urgent?"text-yellow-400 font-bold":"text-slate-400"}`,children:[s.count," ",s.urgent?"pending":"total"]})]}),e.jsx(E,{className:"absolute top-2 right-2 w-4 h-4 text-slate-600 group-hover:text-slate-400 transition-colors"})]},s.tab)})})]}),e.jsxs("div",{className:"bg-slate-800 border border-slate-700 rounded-lg p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Recent Activity"}),e.jsx("button",{onClick:()=>n("transactions"),className:"text-sm text-blue-400 hover:text-blue-300 transition-colors",children:"View All →"})]}),m.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(L,{className:"w-12 h-12 text-slate-600 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-400",children:"No recent activity"})]}):e.jsx("div",{className:"space-y-3",children:m.map((s,i)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-slate-900 rounded-lg hover:bg-slate-700 transition-colors",children:[e.jsx("div",{className:"p-2 bg-slate-800 rounded",children:s.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white text-sm",children:s.text}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:new Date(s.time).toLocaleString()})]}),s.status&&e.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${s.status==="completed"||s.status==="approved"?"bg-green-500/10 text-green-400":s.status==="pending"?"bg-yellow-500/10 text-yellow-400":"bg-red-500/10 text-red-400"}`,children:s.status})]},i))})]}),e.jsxs("div",{className:"bg-slate-800 border border-slate-700 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"System Status"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"w-5 h-5 text-green-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium",children:"Database"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Connected"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"w-5 h-5 text-green-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium",children:"API"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Operational"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"w-5 h-5 text-green-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium",children:"Email"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Active"})]})]})]})]})]})}export{F as default};
