Skip to content

Commit 20f680c

Browse files
committed
Tweak subscription section design
1 parent 3d5b4d1 commit 20f680c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

web/src/app/profile/components/subscription-section.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@ interface SubscriptionApiResponse {
4444
}
4545
}
4646

47-
function formatHours(dateStr: string): string {
47+
function formatDaysHours(dateStr: string): string {
4848
const target = new Date(dateStr)
4949
const now = new Date()
5050
const diffMs = target.getTime() - now.getTime()
5151
if (isNaN(diffMs) || diffMs <= 0) return '0h'
52-
const hours = Math.ceil(diffMs / (1000 * 60 * 60))
52+
const totalHours = Math.ceil(diffMs / (1000 * 60 * 60))
53+
const days = Math.floor(totalHours / 24)
54+
const hours = totalHours % 24
55+
if (days > 0) {
56+
return hours > 0 ? `${days}d ${hours}h` : `${days}d`
57+
}
5358
return `${hours}h`
5459
}
5560

@@ -138,12 +143,16 @@ function SubscriptionActive({
138143
<div className="flex items-center justify-between text-sm">
139144
<span className="font-medium">
140145
Session
146+
{rateLimit.blockResetsAt && (
147+
<span className="font-normal text-muted-foreground ml-1.5">
148+
resets in {formatDaysHours(rateLimit.blockResetsAt)}
149+
</span>
150+
)}
141151
</span>
142152
<span className="text-muted-foreground">
143153
{rateLimit.blockLimit != null && rateLimit.blockUsed != null && rateLimit.blockLimit > 0
144154
? `${Math.round(100 - (rateLimit.blockUsed / rateLimit.blockLimit) * 100)}%`
145155
: '100%'}
146-
{rateLimit.blockResetsAt && ` · Resets in ${formatHours(rateLimit.blockResetsAt)}`}
147156
</span>
148157
</div>
149158
<ProgressBar
@@ -161,9 +170,12 @@ function SubscriptionActive({
161170
<div className="flex items-center justify-between text-sm">
162171
<span className="font-medium">
163172
Weekly
173+
<span className="font-normal text-muted-foreground ml-1.5">
174+
resets in {formatDaysHours(rateLimit.weeklyResetsAt)}
175+
</span>
164176
</span>
165177
<span className="text-muted-foreground">
166-
{100 - rateLimit.weeklyPercentUsed}% · Resets in {formatHours(rateLimit.weeklyResetsAt)}
178+
{100 - rateLimit.weeklyPercentUsed}%
167179
</span>
168180
</div>
169181
<ProgressBar
@@ -178,8 +190,8 @@ function SubscriptionActive({
178190
<AlertTriangle className="mt-0.5 h-4 w-4 flex-shrink-0 text-yellow-600 dark:text-yellow-400" />
179191
<p className="text-sm text-yellow-800 dark:text-yellow-300">
180192
{rateLimit.reason === 'weekly_limit'
181-
? `Weekly limit reached. Resets in ${formatHours(rateLimit.weeklyResetsAt)}. You can still use a-la-carte credits.`
182-
: `Session exhausted. New session in ${rateLimit.blockResetsAt ? formatHours(rateLimit.blockResetsAt) : 'soon'}. You can still use a-la-carte credits.`}
193+
? `Weekly limit reached. Resets in ${formatDaysHours(rateLimit.weeklyResetsAt)}. You can still use a-la-carte credits.`
194+
: `Session exhausted. New session in ${rateLimit.blockResetsAt ? formatDaysHours(rateLimit.blockResetsAt) : 'soon'}. You can still use a-la-carte credits.`}
183195
</p>
184196
</div>
185197
)}

0 commit comments

Comments
 (0)