Skip to content

Commit

Permalink
hotfix: display percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
luistorres committed May 7, 2024
1 parent ed96531 commit f8624ec
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/web-app/app/_ui/project/sale-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ const ProgressBarInfo = () => {
return null;
};

const getDisplayPercentage = (percentage: number) => {
if (percentage > 0 && percentage < 1) {
return 1;
}

if (percentage > 100) {
return 100;
}

return percentage;
};

const ProgressBar = ({
title,
max,
Expand All @@ -47,7 +59,7 @@ const ProgressBar = ({
const halfInMillions = maxInMillions / 2;
const currentRelativeValue = valueInMillions / maxInMillions;
const percentage = currentRelativeValue * 100;
const displayPercentage = percentage > 0 && percentage < 1 ? 1 : percentage;
const displayPercentage = getDisplayPercentage(percentage);
const percentageRounded = `${Math.round(displayPercentage)}%`;
const displayValue =
valueInMillions > 0 && valueInMillions < 0.1
Expand Down

0 comments on commit f8624ec

Please sign in to comment.