import React from "react"; import { Box, Text } from "ink"; import { HeaderSwr } from "../../tui-components/HeaderSwr.jsx"; import { StatusBadge } from "../../tui-components/StatusBadge.jsx"; export default function Health({ baseUrl, apiKey }) { const fetcher = React.useCallback(async () => { const res = await fetch(`${baseUrl}/api/monitoring/health?detail=true`, { headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {}, }); return res.ok ? res.json() : null; }, [baseUrl, apiKey]); return ( { const components = data?.components ?? {}; const alerts = data?.alerts ?? []; return ( Components {Object.entries(components).map(([name, status]) => ( {name} ))} {alerts.length > 0 && ( Alerts ({alerts.length}) {alerts.map((a, i) => ( ⚠ {a.message ?? a} ))} )} ); }} /> ); }