fix(ui): различать нулевые и неизвестные счётчики WireGuard

This commit is contained in:
Denozordec committed 2026-10-04 11:58:10 +07:00
1 parent 53c1bfbd3b
commit 7693b32372
9 files changed
+59 -16

No files matched your search

@@ -12,7 +12,7 @@ import {
} from "lucide-react"
function fmtBytes(n: number | undefined): string {
if (!n) return "—"
if (n === undefined || !Number.isFinite(n) || n < 0) return "—"
if (n >= 1_000_000_000) return `${(n / 1_000_000_000).toFixed(1)} ГБ`
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)} МБ`
if (n >= 1_000) return `${(n / 1_000).toFixed(0)} КБ`
@@ -80,12 +80,12 @@ function WireGuardPeersDetail({
{peer.latestHandshake ?? "нет рукопожатия"}
</span>
<div className="flex items-center gap-2 text-muted-foreground whitespace-nowrap">
<span className="flex items-center gap-0.5">
<ArrowDownIcon className="size-3 text-success" />
<span aria-label="RX" className="flex items-center gap-0.5">
<ArrowDownIcon aria-hidden="true" className="size-3 text-success" />
{fmtBytes(peer.transferRx)}
</span>
<span className="flex items-center gap-0.5">
<ArrowUpIcon className="size-3 text-info" />
<span aria-label="TX" className="flex items-center gap-0.5">
<ArrowUpIcon aria-hidden="true" className="size-3 text-info" />
{fmtBytes(peer.transferTx)}
</span>
</div>
@@ -156,12 +156,12 @@ function WireguardPeersGrid({
enableSorting: false,
cell: ({ row }) => (
<div className="flex items-center gap-2 whitespace-nowrap text-xs text-muted-foreground">
<span className="flex items-center gap-0.5">
<ArrowDownIcon className="size-3 text-success" />
<span aria-label="RX" className="flex items-center gap-0.5">
<ArrowDownIcon aria-hidden="true" className="size-3 text-success" />
{fmtBytes(row.original.transferRx)}
</span>
<span className="flex items-center gap-0.5">
<ArrowUpIcon className="size-3 text-info" />
<span aria-label="TX" className="flex items-center gap-0.5">
<ArrowUpIcon aria-hidden="true" className="size-3 text-info" />
{fmtBytes(row.original.transferTx)}
</span>
</div>