veza/apps/web/dist_verification/assets/AdminDashboardView-BsaSvAAI.js

2 lines
18 KiB
JavaScript
Raw Normal View History

import{a as l,j as e}from"./vendor-react-Dkpvlwai.js";import{a as E,l as k,n as I,B as h,d as u,C as n,S as r,E as _}from"./index-B6VcWW6Q.js";import{ay as U,R as z,aK as B,a_ as M,aT as H,a$ as D,b0 as G,y as V,aF as K,aR as $,A as F,x as Y,E as Q,b1 as W,az as q}from"./vendor-icons-CbmLcMl-.js";import{A as J}from"./AnimatedNumber-DnJWR5Ra.js";import{T as X,a as Z,b as w,c as S}from"./Tabs-DmmEX2O4.js";import{y as R}from"./vendor-CAoAb3tF.js";import"./vendor-router-4bycex72.js";import"./vendor-tanstack-BoI3DtL9.js";import"./vendor-utils-CDFfoeXY.js";const ee=[{id:"r1",targetId:"u3",targetType:"user",targetName:"Bot_User_99",reason:"Spam",description:"Posting same link in 50 channels.",reportedBy:"Admin_Dave",status:"pending",timestamp:"2023-10-25 10:30 AM"},{id:"r2",targetId:"t105",targetType:"track",targetName:"Untitled Track",reason:"Copyright",description:"Direct rip of Skrillex track.",reportedBy:"Sarah Connor",status:"pending",timestamp:"2023-10-25 09:15 AM"},{id:"r3",targetId:"c88",targetType:"comment",targetName:"Comment #8821",reason:"Hate Speech",description:"Offensive language.",reportedBy:"Cyber_Producer",status:"reviewed",timestamp:"2023-10-24 04:20 PM"}],se=[{id:"u1",name:"Bass_Drop.wav",user:"Skrillex",size:"12MB",date:"5 mins ago"},{id:"u2",name:"Project_Alpha.zip",user:"Deadmau5",size:"450MB",date:"12 mins ago"},{id:"u3",name:"Cover_Art.png",user:"Grimes",size:"4MB",date:"20 mins ago"}],g={getDashboardStats:async()=>{try{const s=await E.get("/audit/stats");return!s.data||Object.keys(s.data).length===0?{totalUsers:12450,monthlyRevenue:45290,activeSessions:1840,pendingReports:14,trends:{users:5.2,revenue:12.8,sessions:-2.4,reports:0}}:{totalUsers:s.data.total_users||12450,monthlyRevenue:s.data.total_revenue||45290,activeSessions:s.data.active_sessions||1840,pendingReports:s.data.pending_reports||14,trends:s.data.trends||{users:0,revenue:0,sessions:0,reports:0}}}catch(s){return k.error("[Admin] Failed to fetch dashboard stats",{error:s}),{totalUsers:12450,monthlyRevenue:45290,activeSessions:1840,pendingReports:14,trends:{users:5.2,revenue:12.8,sessions:-2.4,reports:0}}}},getModerationQueue:async(s="pending")=>(await new Promise(t=>setTimeout(t,600)),ee.filter(t=>s==="all"||t.status===s)),resolveReport:async(s,t)=>(await new Promise(o=>setTimeout(o,400)),{success:!0}),getRecentUploads:async()=>(await new Promise(s=>setTimeout(s,400)),se),getAuditLogs:async s=>(await E.get("/audit/logs",{params:s})).data};function ae(){const{addToast:s}=I(),[t,o]=l.useState({}),[d,a]=l.useState([]),[m,v]=l.useState([]),[f,p]=l.useState([]),[b,c]=l.useState(!0),[A,C]=l.useState(null),[L,T]=l.useState(null),N=l.useCallback(async()=>{c(!0),C(null);try{const[i,x,j,y]=await Promise.all([g.getDashboardStats(),g.getModerationQueue("pending"),g.getRecentUploads(),g.getAuditLogs({limit:10})]);o(i),a(x||[]),v(j||[]),p(y?.logs||[])}catch(i){k.error("Error loading admin dashboard",{error:i}),C(i instanceof Error?i:new Error(String(i)))}finally{c(!1)}},[]);l.useEffect(()=>{N()},[N]);const P=l.useCallback(async(i,x)=>{await g.resolveReport(i,x),a(j=>j.filter(y=>y.id!==i)),s(`Protocol "${x.toUpperCase()}" executed successfully.`,"success")},[s]),O=l.useCallback((i,x)=>{T(i),s(`INITIALIZING ${i.toUpperCase()}...`,"info"),setTimeout(()=>{s(`${i.toUpperCase()} DEPLOYED`,x),T(null)},2e3)},[s]);return{stats:t,reports:d,uploads:m,auditLogs:f,loading:b,error:A,protocolActive:L,handleAction:P,triggerProtocol:O,retry:N}}function te({protocolActive:s,onRescan:t,onLockdown:o}){return e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-end justify-between gap-6",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-4xl font-heading font-bold text-foreground mb-2 flex items-center gap-3",children:[e.jsx(U,{className:"text-primary w-10 h-10"})," COMMAND CENTER"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-success animate-pulse shadow-glow-lime"}),e.jsx("span",{className:"text-muted-foreground text-xs