import { Link } from "react-router-dom"; import { Boxes, Container, HeartPulse, ArrowUpCircle, Archive } from "lucide-react"; import type { FleetKpis } from "@/api/dashboard"; import { cn } from "@/lib/utils"; type Tone = "default" | "warn" | "error"; function Kpi({ icon, label, value, sub, tone = "default", to, }: { icon: React.ReactNode; label: string; value: React.ReactNode; sub?: string; tone?: Tone; to?: string; }) { const toneText = tone === "error" ? "text-red-600 dark:text-red-400" : tone === "warn" ? "text-sp-amber" : "text-sp-text-1"; const inner = (
{icon} {label}

{value}

{sub &&

{sub}

}
); return to ? ( {inner} ) : ( inner ); } export function FleetKpiRow({ kpis }: { kpis: FleetKpis }) { return (
} label="Stacks" value={`${kpis.stacks_running}/${kpis.stacks_total}`} sub={kpis.stacks_partial > 0 ? `${kpis.stacks_partial} partial` : "running"} tone={kpis.stacks_partial > 0 ? "warn" : "default"} /> } label="Containers" value={`${kpis.containers_running}/${kpis.containers_total}`} sub="running" /> } label="Unhealthy" value={kpis.unhealthy} sub={kpis.unhealthy > 0 ? "need a look" : "all healthy"} tone={kpis.unhealthy > 0 ? "error" : "default"} /> } label="Updates" value={kpis.updates_available} sub={kpis.updates_available > 0 ? "available" : "up to date"} tone={kpis.updates_available > 0 ? "warn" : "default"} to={kpis.updates_available > 0 ? "/images" : undefined} /> } label="Backups" value={kpis.backups_failing > 0 ? kpis.backups_failing : "OK"} sub={kpis.backups_failing > 0 ? "failing/overdue" : "on schedule"} tone={kpis.backups_failing > 0 ? "error" : "default"} to={kpis.backups_failing > 0 ? "/settings" : undefined} />
); }