admin page fix

This commit is contained in:
user committed 2025-09-26 15:05:21 +03:00
1 parent d08a02b6e7
commit b64b7a3880
3 files changed
+136 -10

No files matched your search

+28 -5
View File
@@ -52,6 +52,29 @@ const formatDate = (iso?: string | null) => {
return dateTimeFormatter.format(date);
};
const formatUnknown = (value: unknown): string => {
if (value === null || value === undefined) {
return "—";
}
if (typeof value === "string") {
return value || "—";
}
if (typeof value === "number" || typeof value === "bigint") {
return numberFormatter.format(Number(value));
}
if (typeof value === "boolean") {
return value ? "Да" : "Нет";
}
if (value instanceof Date) {
return formatDate(value.toISOString());
}
try {
return JSON.stringify(value);
} catch (error) {
return String(value);
}
};
const Section = ({
id,
title,
@@ -661,7 +684,7 @@ export const AdminPage = () => {
<h3 className="text-sm font-semibold uppercase tracking-wide text-slate-400">Окружение</h3>
<dl className="mt-3 space-y-2">
{Object.entries(env).map(([key, value]) => (
<InfoRow key={key} label={key}>{value ?? "—"}</InfoRow>
<InfoRow key={key} label={key}>{formatUnknown(value)}</InfoRow>
))}
</dl>
</div>
@@ -702,8 +725,8 @@ export const AdminPage = () => {
{service_config.map((item) => (
<tr key={item.key}>
<td className="px-3 py-2 font-mono text-xs text-slate-300">{item.key}</td>
<td className="px-3 py-2">{item.value ?? "—"}</td>
<td className="px-3 py-2 font-mono text-xs text-slate-500">{item.raw ?? "—"}</td>
<td className="px-3 py-2">{formatUnknown(item.value)}</td>
<td className="px-3 py-2 font-mono text-xs text-slate-500">{formatUnknown(item.raw)}</td>
</tr>
))}
</tbody>
@@ -770,7 +793,7 @@ export const AdminPage = () => {
<tr key={task.id} className="hover:bg-slate-900/50">
<td className="px-3 py-2 font-mono text-xs text-slate-300">{task.id}</td>
<td className="px-3 py-2">{task.destination || "—"}</td>
<td className="px-3 py-2">{task.amount || "—"}</td>
<td className="px-3 py-2">{formatUnknown(task.amount)}</td>
<td className="px-3 py-2"><Badge tone={task.status === "done" ? "success" : task.status === "failed" ? "danger" : "neutral"}>{task.status}</Badge></td>
<td className="px-3 py-2">{task.epoch ?? "—"} · {task.seqno ?? "—"}</td>
<td className="px-3 py-2 font-mono text-xs text-slate-500">{task.transaction_hash || "—"}</td>
@@ -836,7 +859,7 @@ export const AdminPage = () => {
</td>
<td className="px-3 py-2">{node.version || "—"}</td>
<td className="px-3 py-2">{formatDate(node.last_seen)}</td>
<td className="px-3 py-2">{node.notes || "—"}</td>
<td className="px-3 py-2">{formatUnknown(node.notes)}</td>
</tr>
))}
</tbody>