import React, { useMemo } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../contexts/AuthContext'; import { useAgents } from '../contexts/AgentContext'; import AgentCard from '../components/AgentCard'; // We'll update this next import ProfileDropdown from '../components/ProfileDropdown'; import { Box, Typography, Container, Grid, CircularProgress, IconButton, Tooltip, Fade } from '@mui/material'; import { Add as AddIcon, Logout as LogoutIcon, Dashboard as DashboardIcon, Storage as StorageIcon, Speed as SpeedIcon, Diamond as DiamondIcon, Description as DescriptionIcon } from '@mui/icons-material'; const Dashboard = () => { const { user, logout } = useAuth(); const { agents, loading, fetchAgents } = useAgents(); const navigate = useNavigate(); // Force refresh on mount React.useEffect(() => { fetchAgents(); }, [fetchAgents]); // Calculate stats const stats = useMemo(() => { const totalAgents = agents.length; const totalDocs = agents.reduce((acc, curr) => acc + (curr.stats?.source_files || 0), 0); const activeAgents = agents.filter(a => a.status === 'ready').length; return { totalAgents, totalDocs, activeAgents }; }, [agents]); return ( {/* Animated Background */}
{/* Glass Header */} MEXAR Ultimate {/* Welcome Section */} Your Agents Manage and deploy your reasoning engines {/* Stats Cards */} {stats.totalAgents} Total Agents {stats.activeAgents} Active & Ready {stats.totalDocs} Total Documents {/* Agents Grid */} {loading ? ( ) : ( <> {agents.length === 0 ? ( No agents yet Create your first AI reasoning agent by uploading documents. MEXAR will build a knowledge graph and vector index automatically. ) : ( {agents.map((agent, index) => (
))}
)} )}
); }; export default Dashboard;