import type { ReactNode } from "react"; import type { PollState } from "@/types/monitor"; type Tone = "mint" | "blue" | "coral"; const toneStyles: Record = { mint: "from-white via-white to-emerald-50 ring-emerald-100", blue: "from-white via-white to-sky-50 ring-sky-100", coral: "from-white via-white to-rose-50 ring-rose-100", }; interface ECGMonitorCardProps { title: string; endpoint: string; intervalLabel: string; tone?: Tone; now: string; wavePoints: string; waveHeight: number; healthy: boolean; loading: boolean; statusLabel: string; statusDetail: string; lastUpdatedLabel: string; state: PollState; children?: ReactNode; onManualTrigger: () => void; } /** * Presentational card that renders endpoint status and the shared ECG waveform with * consistent tone, status badges, and contextual metadata. */ export function ECGMonitorCard({ title, endpoint, intervalLabel, tone = "mint", now, wavePoints, waveHeight, healthy, loading, statusLabel, statusDetail, lastUpdatedLabel, state, children, onManualTrigger, }: ECGMonitorCardProps) { const signalId = `${endpoint.replace(/[^a-z0-9]/gi, "-")}-stroke`; const badgeColor = loading ? "border-amber-200 bg-amber-50 text-amber-800" : healthy ? "border-emerald-200 bg-emerald-50 text-emerald-800" : "border-rose-200 bg-rose-50 text-rose-800"; const dotColor = loading ? "bg-pulse" : healthy ? "bg-success" : "bg-danger"; const strokeColor = loading ? "#f59e0b" : healthy ? "#22c55e" : "#ef4444"; return (
{endpoint}

{title}

every {intervalLabel}

{statusLabel}
{now}

Last updated

{lastUpdatedLabel}

ECG signal {loading ? "Polling" : healthy ? "Healthy" : "Unhealthy"}

Status

{statusDetail}

Endpoint

{state.attemptedUrl}

{children}
); }