import { AlertTriangleIcon, CheckCircle2Icon } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert"; import { useHealthCheck } from "src/hooks/useHealthCheck"; import { AlbyInfoIncident, HealthAlarm } from "src/types"; import { ExternalLinkButton } from "../ui/custom/external-link-button"; export function HealthCheckAlert() { const { data: health } = useHealthCheck(); const ok = !health?.alarms?.length; if (!health) { return null; } if (ok) { return null; } function getAlarmTitle(alarm: HealthAlarm) { // TODO: could show extra data from alarm.rawDetails // for some alarm types try { switch (alarm.kind) { case "alby_service": return ( "Alby Services: " + (alarm.rawDetails as AlbyInfoIncident[]) ?.map((incident) => `${incident.name} (${incident.status})`) .join(", ") ); case "channels_offline": return "One or more channels are offline"; case "node_not_ready": return "Node is not ready"; case "nostr_relay_offline": return ( "Could not connect to relay: " + (alarm.rawDetails as string[]).join(", ") ); case "vss_no_subscription": return "Your lightning channel data is stored encrypted by Alby's Versioned Storage Service which is a paid feature. Restart your subscription or send your funds to another wallet as soon as possible."; } } catch (error) { console.error("failed to parse alarm details", alarm.kind, error); } return alarm.kind || "Unknown"; } return ( <> {ok ? ( <> Alby Hub is running smoothly ) : ( <> {health.alarms.length} issues impacting your hub were found )} {health.alarms?.length && (
    {health.alarms?.map((alarm) => (
  • {getAlarmTitle(alarm)}
  • ))}
)}
Alby Service Status Learn More
); }