import React, { useMemo } from 'react'; import { RefreshCw, Activity, MessageSquare, Clock, Server, CheckCircle2, Pause } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { useAppContext } from '../context/AppContext'; import StatCard from '../components/StatCard'; const Dashboard: React.FC = () => { const { t } = useTranslation(); const { isGatewayOnline, sessions, cron, nodes, refreshAll, gatewayVersion, webuiVersion } = useAppContext(); const onlineNodes = useMemo(() => { try { const arr = JSON.parse(nodes); return Array.isArray(arr) ? arr.filter((n: any) => n?.online).length : 0; } catch { return 0; } }, [nodes]); return (

{t('dashboard')}

Gateway: {gatewayVersion} ยท WebUI: {webuiVersion}
} /> } /> } /> } />

{t('recentCron')}

{cron.slice(0, 5).map(j => (
{j.name || j.id} {j.enabled ? ( {t('active')} ) : ( {t('paused')} )}
))} {cron.length === 0 &&
{t('noCronJobs')}
}

{t('nodesSnapshot')}

{(() => { try { const parsedNodes = JSON.parse(nodes); if (!Array.isArray(parsedNodes) || parsedNodes.length === 0) { return
{t('noNodes')}
; } return (
{parsedNodes.map((node: any, i: number) => (
{node.name || node.id || `Node ${i + 1}`}
{node.version || node.ip || ''}
))}
); } catch (e) { return
{nodes}
; } })()}
); }; export default Dashboard;