From bdc3513a6811a723afd8a5a91f7584950a694aa7 Mon Sep 17 00:00:00 2001 From: sagit Date: Wed, 11 Feb 2026 02:17:38 +0000 Subject: [PATCH] fix(panel-sharing): use adaptive units in formatFlowGB to display small traffic values --- vite-frontend/src/pages/panel-sharing.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vite-frontend/src/pages/panel-sharing.tsx b/vite-frontend/src/pages/panel-sharing.tsx index 4fb6626..fdd881c 100644 --- a/vite-frontend/src/pages/panel-sharing.tsx +++ b/vite-frontend/src/pages/panel-sharing.tsx @@ -275,9 +275,13 @@ export default function PanelSharingPage() { const formatFlowGB = (bytes: number) => { if (!Number.isFinite(bytes) || bytes <= 0) { - return "0.00 GB"; + return "0 B"; } - return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`; + if (bytes < 1024) return bytes + " B"; + if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + " KB"; + if (bytes < 1024 * 1024 * 1024) + return (bytes / (1024 * 1024)).toFixed(2) + " MB"; + return (bytes / (1024 * 1024 * 1024)).toFixed(2) + " GB"; }; const formatChainType = (chainType: number, hopInx: number) => {