Skip to content

Commit b622fa7

Browse files
committed
fix: progress bar in billing
1 parent 1cb9033 commit b622fa7

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

apps/dashboard/app/(main)/billing/components/usage-row.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ export const UsageRow = memo(function UsageRowComponent({
5353
}: {
5454
feature: FeatureUsage;
5555
}) {
56-
const remainingPercent = feature.unlimited
57-
? 100
58-
: Math.min(Math.max((feature.balance / feature.limit) * 100, 0), 100);
56+
const used = feature.limit - feature.balance;
57+
const usedPercent = feature.unlimited
58+
? 0
59+
: Math.min(Math.max((used / feature.limit) * 100, 0), 100);
5960
const hasNormalLimit = !(feature.unlimited || feature.hasExtraCredits);
60-
const isLow = hasNormalLimit && remainingPercent < 20;
61+
const isLow = hasNormalLimit && usedPercent > 80;
6162
const hasOverage = feature.overage !== null;
6263

6364
const Icon = getFeatureIcon(feature.name);
@@ -110,9 +111,9 @@ export const UsageRow = memo(function UsageRowComponent({
110111
) : feature.hasExtraCredits ? (
111112
<div className="text-right">
112113
<span className="font-mono text-base">
113-
{formatCompactNumber(feature.balance)}
114+
{formatCompactNumber(used)}
114115
</span>
115-
<div className="text-muted-foreground text-xs">remaining</div>
116+
<div className="text-muted-foreground text-xs">used</div>
116117
</div>
117118
) : feature.overage ? (
118119
<div className="text-right">
@@ -131,10 +132,9 @@ export const UsageRow = memo(function UsageRowComponent({
131132
isLow ? "text-warning" : "text-foreground"
132133
)}
133134
>
134-
{formatCompactNumber(feature.balance)} /{" "}
135-
{formatCompactNumber(feature.limit)}
135+
{formatCompactNumber(used)} / {formatCompactNumber(feature.limit)}
136136
</span>
137-
<div className="text-muted-foreground text-xs">remaining</div>
137+
<div className="text-muted-foreground text-xs">used</div>
138138
</div>
139139
)}
140140
</div>
@@ -151,7 +151,7 @@ export const UsageRow = memo(function UsageRowComponent({
151151
? "bg-warning"
152152
: "bg-primary"
153153
)}
154-
style={{ width: hasOverage ? "100%" : `${remainingPercent}%` }}
154+
style={{ width: hasOverage ? "100%" : `${usedPercent}%` }}
155155
/>
156156
</div>
157157
{(isLow || hasOverage) && (

apps/dashboard/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "dotenv -- bun --bun next dev -p 3000",
6+
"dev": "bun --bun next dev -p 3000",
77
"build": "next build",
88
"start": "next start -p 3000",
9-
"typecheck": "tsgo --noEmit",
10-
"build:script": "bun build ./public/databuddy.ts --outfile ./public/databuddy.js --minify"
9+
"typecheck": "tsgo --noEmit"
1110
},
1211
"dependencies": {
1312
"@databuddy/auth": "workspace:*",

0 commit comments

Comments
 (0)