reliability semi-fix

This commit is contained in:
Marcelo
2026-04-24 14:06:15 +00:00
parent 4973c18dc3
commit 6aaafb9115
32 changed files with 3749 additions and 1093 deletions

View File

@@ -1,44 +1,32 @@
"use client";
import { useI18n } from "@/lib/i18n/useI18n";
import type { RecapMachine } from "@/lib/recap/types";
type Props = {
machine: RecapMachine | null;
heartbeat: {
lastSeenAt: string | null;
uptimePct: number | null;
connectionStatus: "online" | "offline";
};
};
export default function RecapMachineStatus({ machine }: Props) {
export default function RecapMachineStatus({ heartbeat }: Props) {
const { t, locale } = useI18n();
if (!machine) {
return (
<div className="rounded-2xl border border-white/10 bg-black/40 p-4">
<div className="text-sm text-zinc-400">{t("recap.empty.production")}</div>
</div>
);
}
const isStopped = (machine.downtime.ongoingStopMin ?? 0) > 0;
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={isStopped ? "text-red-400" : "text-emerald-400"}>
{isStopped ? t("recap.machine.stopped") : t("recap.machine.running")}
</span>
</li>
<li>
<span className={machine.workOrders.moldChangeInProgress ? "text-amber-400" : "text-zinc-300"}>
{t("recap.machine.mold")}: {machine.workOrders.moldChangeInProgress ? t("common.yes") : t("common.no")}
<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")}: {machine.heartbeat.lastSeenAt ? new Date(machine.heartbeat.lastSeenAt).toLocaleString(locale) : "--"}
{t("recap.machine.lastHeartbeat")}: {heartbeat.lastSeenAt ? new Date(heartbeat.lastSeenAt).toLocaleString(locale) : "--"}
</li>
<li className="text-zinc-400">
{t("recap.machine.uptime")}: {machine.heartbeat.uptimePct == null ? "--" : `${machine.heartbeat.uptimePct.toFixed(1)}%`}
{t("recap.machine.uptime")}: {heartbeat.uptimePct == null ? "--" : `${heartbeat.uptimePct.toFixed(1)}%`}
</li>
</ul>
</div>