diff --git a/src/components/ClientMonitor/ClientMonitorPage.tsx b/src/components/ClientMonitor/ClientMonitorPage.tsx
index eaebdc6..681f1fc 100644
--- a/src/components/ClientMonitor/ClientMonitorPage.tsx
+++ b/src/components/ClientMonitor/ClientMonitorPage.tsx
@@ -27,7 +27,17 @@ import Search from "@mui/icons-material/Search";
import PageTitleBar from "@/components/PageTitleBar";
import { NEXT_PUBLIC_API_URL } from "@/config/api";
import { clientAuthFetch } from "@/app/utils/clientAuthFetch";
+import { arrayToDateTimeString } from "@/app/utils/formatUtil";
import dayjs from "dayjs";
+
+function formatApiDateTime(value: unknown): string {
+ if (value == null) return "—";
+ if (Array.isArray(value)) {
+ return arrayToDateTimeString(value as (number | undefined)[]);
+ }
+ const d = dayjs(value as string | number);
+ return d.isValid() ? d.format("YYYY-MM-DD HH:mm:ss") : "—";
+}
import PrinterMonitorTab from "@/components/ClientMonitor/PrinterMonitorTab";
type ClientRow = {
@@ -383,17 +393,17 @@ export default function ClientMonitorPage() {
{formatAgo(row.secondsSinceHeartbeat)}
- {row.lastHeartbeat && (
-
- {dayjs(row.lastHeartbeat).format("HH:mm:ss")}
-
- )}
-
-
- {row.lastActivity
- ? dayjs(row.lastActivity).format("HH:mm:ss")
- : "—"}
+ {row.lastHeartbeat && (
+
+ {formatApiDateTime(row.lastHeartbeat).slice(11)}
+
+ )}
+
+ {row.lastActivity
+ ? formatApiDateTime(row.lastActivity).slice(11)
+ : "—"}
+
);
})
@@ -528,11 +538,7 @@ export default function ClientMonitorPage() {
const st = STATUS_LABEL[row.status] ?? STATUS_LABEL.offline;
return (
-
- {row.recordedAt
- ? dayjs(row.recordedAt).format("YYYY-MM-DD HH:mm:ss")
- : "—"}
-
+ {formatApiDateTime(row.recordedAt)}
diff --git a/src/components/ClientMonitor/PrinterMonitorTab.tsx b/src/components/ClientMonitor/PrinterMonitorTab.tsx
index adc0b86..a07cfa3 100644
--- a/src/components/ClientMonitor/PrinterMonitorTab.tsx
+++ b/src/components/ClientMonitor/PrinterMonitorTab.tsx
@@ -16,8 +16,18 @@ import {
} from "@mui/material";
import { NEXT_PUBLIC_API_URL } from "@/config/api";
import { clientAuthFetch } from "@/app/utils/clientAuthFetch";
+import { arrayToDateTimeString } from "@/app/utils/formatUtil";
import dayjs from "dayjs";
+function formatApiDateTime(value: unknown): string {
+ if (value == null) return "—";
+ if (Array.isArray(value)) {
+ return arrayToDateTimeString(value as (number | undefined)[]);
+ }
+ const d = dayjs(value as string | number);
+ return d.isValid() ? d.format("YYYY-MM-DD HH:mm:ss") : "—";
+}
+
type PrinterRow = {
id: number;
code?: string;
@@ -172,11 +182,7 @@ export default function PrinterMonitorTab({ active, refreshAt = 0 }: Props) {
{row.errorMessage ?? "無法連線"}
-
- {row.lastCheckAt
- ? dayjs(row.lastCheckAt).format("YYYY-MM-DD HH:mm:ss")
- : "—"}
-
+ {formatApiDateTime(row.lastCheckAt)}
))}
@@ -241,11 +247,7 @@ export default function PrinterMonitorTab({ active, refreshAt = 0 }: Props) {
{row.latencyMs != null ? row.latencyMs : "—"}
-
- {row.lastCheckAt
- ? dayjs(row.lastCheckAt).format("YYYY-MM-DD HH:mm:ss")
- : "—"}
-
+ {formatApiDateTime(row.lastCheckAt)}
);
})