Skip to content

[ubp] smaller balance view impr #15176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions components/dashboard/src/components/UsageBasedBillingConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
};

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

return (
<div className="mb-16">
Expand Down Expand Up @@ -237,18 +237,18 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
</div>
<div className="mt-4 text-sm flex text-gray-400 dark:text-gray-500">
<span className="flex-grow">
<span>Monthly limit: {usageLimit} Credits</span>
{showManageBilling && (
<>
<span>&nbsp;&middot;&nbsp;</span>
<span className="gp-link" onClick={() => setShowUpdateLimitModal(true)}>
Update limit
</span>
</>
)}
{typeof currentUsage === "number" &&
typeof usageLimit === "number" &&
usageLimit > 0 && <span>{percentage}% remaining</span>}
</span>
{typeof currentUsage === "number" && typeof usageLimit === "number" && usageLimit > 0 && (
<span>{percentage}% remaining</span>
<span>Monthly limit: {usageLimit} Credits</span>
{showManageBilling && (
<>
<span>&nbsp;&middot;&nbsp;</span>
<span className="gp-link" onClick={() => setShowUpdateLimitModal(true)}>
Update limit
</span>
</>
)}
</div>
<div className="mt-2 flex">
Expand Down