Files
MIS-Contro-Tower/components/recap/RecapMachineStatus.tsx
2026-04-24 14:06:15 +00:00

35 lines
1.2 KiB
TypeScript

"use client";
import { useI18n } from "@/lib/i18n/useI18n";
type Props = {
heartbeat: {
lastSeenAt: string | null;
uptimePct: number | null;
connectionStatus: "online" | "offline";
};
};
export default function RecapMachineStatus({ heartbeat }: Props) {
const { t, locale } = useI18n();
return (
<div className="rounded-2xl border border-white/10 bg-black/40 p-4">
<div className="mb-3 text-sm font-semibold text-white">{t("recap.machine.title")}</div>
<ul className="space-y-2 text-sm text-zinc-200">
<li>
<span className={heartbeat.connectionStatus === "online" ? "text-emerald-300" : "text-red-300"}>
{heartbeat.connectionStatus === "online" ? t("recap.machine.online") : t("recap.machine.offline")}
</span>
</li>
<li className="text-zinc-400">
{t("recap.machine.lastHeartbeat")}: {heartbeat.lastSeenAt ? new Date(heartbeat.lastSeenAt).toLocaleString(locale) : "--"}
</li>
<li className="text-zinc-400">
{t("recap.machine.uptime")}: {heartbeat.uptimePct == null ? "--" : `${heartbeat.uptimePct.toFixed(1)}%`}
</li>
</ul>
</div>
);
}