Skip to content

Commit

Permalink
chore: fix floating value ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-arc10 committed Dec 2, 2024
1 parent 29c3952 commit f639b65
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apps/provider-console/src/components/dashboard/ResourcesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
};

Expand Down

0 comments on commit f639b65

Please sign in to comment.