Skip to content

Commit 2da149e

Browse files
svenefftingeroboquat
authored andcommitted
[ubp] smaller balance view impr
1 parent 7797eb5 commit 2da149e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

components/dashboard/src/components/UsageBasedBillingConfig.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
207207
};
208208

209209
const balance = currentUsage * -1 + usageLimit;
210-
const percentage = Math.max(Math.round((balance * 100) / usageLimit), 0);
210+
const percentage = usageLimit === 0 ? 0 : Math.max(Math.round((balance * 100) / usageLimit), 0);
211211

212212
return (
213213
<div className="mb-16">
@@ -237,18 +237,18 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
237237
</div>
238238
<div className="mt-4 text-sm flex text-gray-400 dark:text-gray-500">
239239
<span className="flex-grow">
240-
<span>Monthly limit: {usageLimit} Credits</span>
241-
{showManageBilling && (
242-
<>
243-
<span>&nbsp;&middot;&nbsp;</span>
244-
<span className="gp-link" onClick={() => setShowUpdateLimitModal(true)}>
245-
Update limit
246-
</span>
247-
</>
248-
)}
240+
{typeof currentUsage === "number" &&
241+
typeof usageLimit === "number" &&
242+
usageLimit > 0 && <span>{percentage}% remaining</span>}
249243
</span>
250-
{typeof currentUsage === "number" && typeof usageLimit === "number" && usageLimit > 0 && (
251-
<span>{percentage}% remaining</span>
244+
<span>Monthly limit: {usageLimit} Credits</span>
245+
{showManageBilling && (
246+
<>
247+
<span>&nbsp;&middot;&nbsp;</span>
248+
<span className="gp-link" onClick={() => setShowUpdateLimitModal(true)}>
249+
Update limit
250+
</span>
251+
</>
252252
)}
253253
</div>
254254
<div className="mt-2 flex">

0 commit comments

Comments
 (0)