import type { WidgetData } from "@/widgets"; import type { Item } from "@/types"; import { cn } from "@/lib/utils"; import { t } from "@/i18n"; // Board tile for an uptime monitor: status dot, uptime %, avg ping. // config.monitorId binds it; data comes from the monitor fetcher. export function MonitorWidget({ item, data, error }: { item: Item; data: WidgetData | undefined; error: string | undefined; }) { const status = typeof data?.status === "string" ? data.status : undefined; const uptime = typeof data?.uptime24 === "number" ? data.uptime24 : undefined; const ping = typeof data?.ping === "number" ? data.ping : undefined; const monId = typeof item.config?.monitorId === "string" ? item.config.monitorId : ""; return ( e.stopPropagation()} > {typeof data?.name === "string" ? data.name : item.name} {error ? t("widget.err") : uptime !== undefined ? `${uptime.toFixed(1)}%` : "…"} {ping ? ` · ${Math.round(ping)}ms` : ""} ); }