Skip to content

Commit 744b002

Browse files
committed
fix: Settings page shows actual tier and repo limit instead of hardcoded 'Free' (OPE-158)
Bug: Settings page had const MAX_REPOS = 3 hardcoded and 'Free tier limit' text for ALL users. Enterprise users saw '5/3 - 0 slots available'. Fix: Uses useUserUsage hook for actual tier and repo limit. - 'Free tier limit' -> 'Enterprise tier limit' (dynamic, capitalized) - '5/3' -> '5/10' for Enterprise (actual limit from backend) - Removed hardcoded MAX_REPOS constant Closes OPE-158
1 parent 3bd3470 commit 744b002

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

frontend/src/pages/SettingsPage.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@ import {
2020
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
2121
import { toast } from 'sonner'
2222
import { API_URL } from '@/config/api'
23+
import { useUserUsage } from '@/hooks/useCachedQuery'
2324

2425
interface Repository {
2526
id: string
2627
name: string
2728
}
2829

29-
const MAX_REPOS = 3
3030
const DELETE_CONFIRMATION_TEXT = 'delete all'
3131

3232
export function SettingsPage() {
3333
const { user, session } = useAuth()
34+
const { data: usage } = useUserUsage(session?.access_token, session?.user?.id)
35+
const maxRepos = usage?.repositories?.limit ?? 1
36+
const tier = usage?.tier || 'free'
3437
const { status, checkStatus, disconnect, loading: githubLoading } = useGitHubRepos()
3538

3639
const [repos, setRepos] = useState<Repository[]>([])
@@ -135,7 +138,7 @@ export function SettingsPage() {
135138
}
136139

137140
const isDeleteEnabled = deleteConfirmation === DELETE_CONFIRMATION_TEXT
138-
const availableSlots = Math.max(0, MAX_REPOS - repos.length)
141+
const availableSlots = Math.max(0, maxRepos - repos.length)
139142

140143
return (
141144
<div className="max-w-2xl space-y-6">
@@ -239,7 +242,7 @@ export function SettingsPage() {
239242
<div className="flex items-center justify-between py-2">
240243
<div>
241244
<p className="font-medium">Repository slots</p>
242-
<p className="text-sm text-muted-foreground">Free tier limit</p>
245+
<p className="text-sm text-muted-foreground capitalize">{tier} tier limit</p>
243246
</div>
244247
<div className="text-right">
245248
{reposLoading ? (
@@ -248,7 +251,7 @@ export function SettingsPage() {
248251
<>
249252
<p className="text-2xl font-bold">
250253
{repos.length}
251-
<span className="text-lg font-normal text-muted-foreground"> / {MAX_REPOS}</span>
254+
<span className="text-lg font-normal text-muted-foreground"> / {maxRepos}</span>
252255
</p>
253256
<p className="text-sm text-muted-foreground">
254257
{availableSlots} slot{availableSlots !== 1 ? 's' : ''} available

0 commit comments

Comments
 (0)