diff --git a/src/App.tsx b/src/App.tsx index 2ac8252..5a0cc44 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,7 @@ import { useTranslation } from 'react-i18next' import { Link } from 'react-router-dom' import Layout from './components/Layout' import { useStats } from './contexts/StatsContext' +import { useServers } from './contexts/ServerContext' import './App.css' // Loading Skeleton Component @@ -37,6 +38,21 @@ const LoadingSkeleton = ({ width = '60px', height = '40px', className = '' }: { function App() { const { t } = useTranslation() const { stats, recentChats, topPlayers, loading } = useStats() + const { servers } = useServers() + + // Calculate server statistics + const onlineServers = servers.filter(s => s.status === 'online') + const totalPlayers = onlineServers.reduce((sum, s) => sum + (s.a2sData ? (s.a2sData.playerCount - s.a2sData.botCount) : 0), 0) + const totalSlots = onlineServers.reduce((sum, s) => sum + (s.a2sData?.maxPlayers || 0), 0) + + // Get most popular server (highest player count) + const mostPopularServer = onlineServers.length > 0 + ? onlineServers.reduce((prev, current) => { + const prevPlayers = (prev.a2sData?.playerCount || 0) - (prev.a2sData?.botCount || 0) + const currentPlayers = (current.a2sData?.playerCount || 0) - (current.a2sData?.botCount || 0) + return currentPlayers > prevPlayers ? current : prev + }) + : null // Format playtime from seconds to hours and minutes const formatPlayTime = (seconds: number) => { @@ -217,9 +233,56 @@ function App() {