@@ -20,17 +20,20 @@ import {
2020import { Alert , AlertDescription , AlertTitle } from '@/components/ui/alert'
2121import { toast } from 'sonner'
2222import { API_URL } from '@/config/api'
23+ import { useUserUsage } from '@/hooks/useCachedQuery'
2324
2425interface Repository {
2526 id : string
2627 name : string
2728}
2829
29- const MAX_REPOS = 3
3030const DELETE_CONFIRMATION_TEXT = 'delete all'
3131
3232export 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