@@ -10,8 +10,7 @@ import { useRouter } from "next/navigation";
1010import Sidebar from "@/app/components/Sidebar" ;
1111import PageHeader from "@/app/components/PageHeader" ;
1212import { colors } from "@/app/lib/colors" ;
13- import { usePaginatedList } from "@/app/hooks/usePaginatedList" ;
14- import { useInfiniteScroll } from "@/app/hooks/useInfiniteScroll" ;
13+ import { usePaginatedList , useInfiniteScroll } from "@/app/hooks" ;
1514import ConfigCard from "@/app/components/ConfigCard" ;
1615import Loader , { LoaderBox } from "@/app/components/Loader" ;
1716import { EvalJob } from "@/app/components/types" ;
@@ -46,8 +45,8 @@ export default function ConfigLibraryPage() {
4645 Record < string , number >
4746 > ( { } ) ;
4847 const { sidebarCollapsed } = useApp ( ) ;
49- const { activeKey } = useAuth ( ) ;
50- const apiKey = activeKey ?. key ;
48+ const { activeKey, isAuthenticated } = useAuth ( ) ;
49+ const apiKey = activeKey ?. key ?? "" ;
5150 const [ searchInput , setSearchInput ] = useState ( "" ) ;
5251 const [ debouncedQuery , setDebouncedQuery ] = useState ( "" ) ;
5352 const [ columnCount , setColumnCount ] = useState ( 3 ) ;
@@ -101,11 +100,11 @@ export default function ConfigLibraryPage() {
101100
102101 useEffect ( ( ) => {
103102 const fetchEvaluationCounts = async ( ) => {
104- if ( ! activeKey ) return ;
103+ if ( ! isAuthenticated ) return ;
105104 try {
106105 const data = await apiFetch < EvalJob [ ] | { data : EvalJob [ ] } > (
107106 "/api/evaluations" ,
108- activeKey . key ,
107+ apiKey ,
109108 ) ;
110109 const jobs : EvalJob [ ] = Array . isArray ( data ) ? data : data . data || [ ] ;
111110 const counts : Record < string , number > = { } ;
@@ -130,7 +129,7 @@ export default function ConfigLibraryPage() {
130129 await existing ;
131130 return ;
132131 }
133- if ( ! apiKey ) return ;
132+ if ( ! isAuthenticated ) return ;
134133
135134 const loadPromise = ( async ( ) => {
136135 const res = await apiFetch < {
@@ -145,15 +144,15 @@ export default function ConfigLibraryPage() {
145144 pendingVersionLoads . set ( configId , loadPromise ) ;
146145 await loadPromise ;
147146 } ,
148- [ apiKey ] ,
147+ [ apiKey , isAuthenticated ] ,
149148 ) ;
150149
151150 const loadSingleVersion = useCallback (
152151 async ( configId : string , version : number ) : Promise < SavedConfig | null > => {
153152 const key = `${ configId } :${ version } ` ;
154153 const existing = pendingSingleVersionLoads . get ( key ) ;
155154 if ( existing ) return existing ;
156- if ( ! apiKey ) return null ;
155+ if ( ! isAuthenticated ) return null ;
157156
158157 const configPublic =
159158 configs . find ( ( c ) => c . id === configId ) ??
@@ -180,7 +179,7 @@ export default function ConfigLibraryPage() {
180179 pendingSingleVersionLoads . set ( key , loadPromise ) ;
181180 return loadPromise ;
182181 } ,
183- [ apiKey , configs ] ,
182+ [ apiKey , configs , isAuthenticated ] ,
184183 ) ;
185184
186185 const handleCreateNew = ( ) => {
@@ -278,17 +277,7 @@ export default function ConfigLibraryPage() {
278277 ) : error ? (
279278 < div className = "rounded-lg p-6 text-center bg-[#fef2f2] border border-[#fecaca]" >
280279 < WarningTriangleIcon className = "w-12 h-12 mx-auto mb-3 text-[#dc2626]" />
281- < p className = "text-sm font-medium text-[#dc2626]" > { error } </ p >
282- < button
283- onClick = { ( ) => router . push ( "/keystore" ) }
284- className = "mt-4 px-4 py-2 rounded-md text-sm font-medium transition-colors"
285- style = { {
286- backgroundColor : colors . accent . primary ,
287- color : colors . bg . primary ,
288- } }
289- >
290- Go to Keystore
291- </ button >
280+ < p className = "text-sm font-medium text-status-error" > { error } </ p >
292281 </ div >
293282 ) : configs . length === 0 ? (
294283 < div
0 commit comments