1- 'use client' ;
2-
31import { DataTable } from "@/components/ui/data-table" ;
42import { columns , RepositoryColumnInfo } from "./columns" ;
3+ import { listRepositories } from "@/lib/server/searchService" ;
54import { isServiceError } from "@/lib/utils" ;
6- import { useQuery } from "@tanstack/react-query" ;
7- import { useMemo } from "react" ;
8- import { getRepos } from "../api/(client)/client" ;
95
10- export const RepositoryTable = ( ) => {
11- const { data : _repos } = useQuery ( {
12- queryKey : [ "repos" ] ,
13- queryFn : ( ) => getRepos ( ) ,
14- enabled : typeof window !== "undefined" ,
15- } ) ;
6+ export const RepositoryTable = async ( ) => {
7+ const _repos = await listRepositories ( ) ;
168
17- const repos = useMemo ( ( ) => {
18- if ( isServiceError ( _repos ) ) {
19- return [ ] ;
20- }
9+ if ( isServiceError ( _repos ) ) {
10+ return < div > Error fetching repositories</ div > ;
11+ }
2112
22- return _repos ?. List . Repos . map ( ( repo ) : RepositoryColumnInfo => ( {
13+ const repos = _repos . List . Repos . map ( ( repo ) : RepositoryColumnInfo => {
14+ return {
2315 name : repo . Repository . Name ,
2416 branches : repo . Repository . Branches . map ( ( branch ) => {
2517 return {
@@ -34,10 +26,10 @@ export const RepositoryTable = () => {
3426 latestCommit : repo . Repository . LatestCommitDate ,
3527 indexedFiles : repo . Stats . Documents ,
3628 commitUrlTemplate : repo . Repository . CommitURLTemplate ,
37- } ) ) . sort ( ( a , b ) => {
38- return new Date ( b . lastIndexed ) . getTime ( ) - new Date ( a . lastIndexed ) . getTime ( ) ;
39- } ) ?? [ ] ;
40- } , [ _repos ] ) ;
29+ }
30+ } ) . sort ( ( a , b ) => {
31+ return new Date ( b . lastIndexed ) . getTime ( ) - new Date ( a . lastIndexed ) . getTime ( ) ;
32+ } ) ;
4133
4234 return (
4335 < DataTable
0 commit comments