import React, { useState, useEffect } from 'react'; import { checkHealth } from '../lib/api/health'; import type { HealthResponse } from '../lib/api/health'; /** * Component that displays the system health information */ export const HealthCheck: React.FC = () => { const [health, setHealth] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchHealth = async () => { try { setLoading(true); const healthData = await checkHealth(); setHealth(healthData); setError(null); } catch (err) { console.error('Error fetching health data:', err); setError('Failed to fetch health information'); } finally { setLoading(false); } }; fetchHealth(); }, []); if (loading) { return
Loading health information...
; } if (error) { return
{error}
; } if (!health) { return
No health information available
; } const systemHealth = health.entries['System Health']; return (

System Health: {systemHealth.status}

{systemHealth.description}

System Metrics

{Object.entries(systemHealth.data).map(([key, value]) => (
{key}: {String(value)}
))}
Total Duration: {health.totalDuration}
); }; export default HealthCheck;