From 598cabca59aa36be9997efbbc47a86198adf2d3e Mon Sep 17 00:00:00 2001 From: Jigar Patel Date: Tue, 3 Dec 2024 01:45:04 +0530 Subject: [PATCH] chore: fix floating value ui --- .../src/components/dashboard/ResourcesCard.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/provider-console/src/components/dashboard/ResourcesCard.tsx b/apps/provider-console/src/components/dashboard/ResourcesCard.tsx index 822c465be..a3e70ee39 100644 --- a/apps/provider-console/src/components/dashboard/ResourcesCard.tsx +++ b/apps/provider-console/src/components/dashboard/ResourcesCard.tsx @@ -20,18 +20,23 @@ const summarizeStatuses = ({ const total = active + pending + available; if (total === 0) return null; + const formatValue = (value: number) => { + if (isBytes) return formatBytes(value); + return Number.isInteger(value) ? value : value.toFixed(2); + }; + const activePercentage = (active / total) * 100; const pendingPercentage = (pending / total) * 100; const availablePercentage = (available / total) * 100; return { - active: isBytes ? formatBytes(active) : active, + active: formatValue(active), activePercentage, - pending: isBytes ? formatBytes(pending) : pending, + pending: formatValue(pending), pendingPercentage, - available: isBytes ? formatBytes(available) : available, + available: formatValue(available), availablePercentage, - total: isBytes ? formatBytes(total) : total + total: formatValue(total) }; };