import { Card, StatusDot } from "@cv/ui"; import type { WorkerHealthQuery } from "@/generated/graphql"; type Worker = WorkerHealthQuery["workerHealth"][number]; type DotColor = "green" | "yellow" | "red"; const statusColor: Record = { healthy: "green", stale: "yellow", dead: "red", }; const formatRelativeTime = (isoString: string): string => { const diff = Date.now() - new Date(isoString).getTime(); const seconds = Math.floor(diff / 1000); if (seconds < 60) return `${seconds}s ago`; const minutes = Math.floor(seconds / 60); if (minutes < 60) return `${minutes}m ago`; const hours = Math.floor(minutes / 60); if (hours < 24) return `${hours}h ago`; return `${Math.floor(hours / 24)}d ago`; }; const truncateUuid = (uuid: string): string => uuid.slice(0, 8); interface WorkerHealthCardProps { workers: Worker[]; } export const WorkerHealthCard = ({ workers }: WorkerHealthCardProps) => (

Workers

{workers.length === 0 ? (

No workers registered

) : (
{workers.map((w) => ( ))}
Worker ID Status Started Last Seen
{truncateUuid(w.workerId)} {w.status} {formatRelativeTime(w.startedAt)} {formatRelativeTime(w.lastSeenAt)}
)}
);