@@ -6,44 +6,47 @@ import { Search } from 'lucide-react';
66import { DashboardSkeleton } from '@/features/dashboard/skeleton' ;
77import { RepositoryCard } from '@/features/dashboard/repo-card' ;
88import { ConnectGitHubView } from '@/features/dashboard/connect-github' ;
9-
10- const MOCK_REPOS = [
11- { id : 1 , title : 'Code Lens Pro' , issueNumber : '#55' , branch : 'main' , avatar : 'https://avatars.githubusercontent.com/u/9919?s=40&v=4' } ,
12- { id : 2 , title : 'Design System V2' , issueNumber : '#102' , branch : 'main' , avatar : 'https://avatars.githubusercontent.com/u/1024025?s=40&v=4' } ,
13- { id : 3 , title : 'API Service Refactor' , issueNumber : '#89' , branch : 'feat/new-auth' , avatar : 'https://avatars.githubusercontent.com/u/9919?s=40&v=4' } ,
14- { id : 4 , title : 'Documentation Site' , issueNumber : '#21' , branch : 'docs-update' , avatar : 'https://avatars.githubusercontent.com/u/1024025?s=40&v=4' } ,
15- { id : 5 , title : 'Mobile App POC' , issueNumber : '#12' , branch : 'main' , avatar : 'https://avatars.githubusercontent.com/u/9919?s=40&v=4' } ,
16- { id : 6 , title : 'E2E Testing Suite' , issueNumber : '#76' , branch : 'ci/playwright' , avatar : 'https://avatars.githubusercontent.com/u/1024025?s=40&v=4' } ,
17- ] ;
9+ import { useRepoQuery } from '@/hooks/queries/useRepoQuery' ;
10+ import { authClient } from '@/lib/auth-client' ;
1811
1912export default function GitHubIntegrationPage ( ) {
2013 const [ accounts , setAccounts ] = useState < any [ ] > ( [ ] ) ;
2114 const [ searchQuery , setSearchQuery ] = useState ( '' ) ;
22- const [ isLoading , setIsLoading ] = useState ( true ) ;
15+
16+ const { data : repos , isPending, error } = useRepoQuery ( ) ;
2317
2418 useEffect ( ( ) => {
2519 const fetchAccounts = async ( ) => {
26- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
27- setAccounts ( [ { providerId : 'github' , accountId : 'user-123' } ] ) ;
28- setIsLoading ( false ) ;
29- } ;
20+ try {
21+ const { data : accountsList , error } = await authClient . listAccounts ( ) ;
22+ if ( accountsList ) {
23+ console . log ( 'Accounts:' , accountsList ) ;
24+ setAccounts ( accountsList ) ;
25+ }
26+ if ( error ) {
27+ console . error ( 'Failed to fetch accounts:' , error ) ;
28+ }
29+ } catch ( error ) {
30+ console . error ( 'Failed to fetch accounts:' , error ) ;
31+ }
32+ }
3033 fetchAccounts ( ) ;
3134 } , [ ] ) ;
3235
3336 const isConnected = ! ! accounts . find ( acc => acc . providerId === 'github' ) ;
3437
3538 const connectGitHub = async ( ) => {
36- setIsLoading ( true ) ;
37- await new Promise ( resolve => setTimeout ( resolve , 1500 ) ) ;
38- setAccounts ( [ { providerId : 'github' , accountId : 'user-123' } ] ) ;
39- setIsLoading ( false ) ;
39+ await authClient . linkSocial ( {
40+ provider : "github" ,
41+ callbackURL : '/dashboard'
42+ } )
4043 } ;
4144
42- const filteredRepos = MOCK_REPOS . filter ( repo =>
43- repo . title . toLowerCase ( ) . includes ( searchQuery . toLowerCase ( ) )
45+ const filteredRepos = repos ? .filter ( ( repo : any ) =>
46+ repo . name . toLowerCase ( ) . includes ( searchQuery . toLowerCase ( ) )
4447 ) ;
4548
46- if ( isLoading ) {
49+ if ( isPending ) {
4750 return < DashboardSkeleton /> ;
4851 }
4952
@@ -76,7 +79,7 @@ export default function GitHubIntegrationPage() {
7679
7780 { /* --- Repository Grid --- */ }
7881 < div className = "overflow-y-auto grid grid-cols-1 md:grid-cols-3 gap-6 pt-6" >
79- { filteredRepos . map ( repo => (
82+ { filteredRepos ? .map ( ( repo : any ) => (
8083 < RepositoryCard key = { repo . id } repo = { repo } />
8184 ) ) }
8285 </ div >
0 commit comments