import { useTranslation } from "react-i18next"; import { Icon } from "@/components/icons"; import { Badge } from "@/components/ui/badge"; import { RelativeTime } from "@/components/shared/relative-time"; import type { HealthResponse } from "@/lib/api"; import { ErrorBlock, LoadingBlock, StatusCard, StatusEmpty } from "./card-parts"; export interface HealthCardProps { health: HealthResponse | undefined; checkedAt: number | null; loading: boolean; error: string | null; onRetry: () => void; } /** Card 2 — per-check ✓/✗ list with an overall healthy/degraded badge. */ export function HealthCard({ health, checkedAt, loading, error, onRetry }: HealthCardProps) { const { t } = useTranslation(); const items = health?.items ?? []; const allOk = items.length > 0 && items.every((item) => item.ok); return ( {items.length ? ( {t(allOk ? "status.healthy" : "state.degraded")} ) : null} {checkedAt ? : null} } > {error ? ( ) : loading ? ( ) : items.length === 0 ? ( ) : (
{items.map((item) => (
{item.name}
{item.detail ?
{item.detail}
: null}
))}
)}
); }