@@ -28,6 +28,23 @@ const YugiohCardDataTable = ( {
2828 const [ lastCheckedKey , setLastCheckedKey ] = useState ( null ) ;
2929 const [ notification , setNotification ] = useState ( { show : false , message : '' } ) ;
3030 const [ internalCollection , setInternalCollection ] = useState ( { } ) ;
31+ const [ isAuthenticated , setIsAuthenticated ] = useState ( false ) ;
32+
33+ useMemo ( ( ) => {
34+ const checkAuth = async ( ) => {
35+ try {
36+ const res = await fetch ( "/api/auth/validate" , {
37+ method : "GET" ,
38+ credentials : "include" ,
39+ } ) ;
40+ setIsAuthenticated ( res . ok ) ;
41+ } catch {
42+ setIsAuthenticated ( false ) ;
43+ }
44+ } ;
45+
46+ checkAuth ( ) ;
47+ } , [ router ] ) ;
3148
3249 const cardIndex = useMemo ( ( ) => {
3350 const map = { } ;
@@ -348,23 +365,18 @@ const YugiohCardDataTable = ( {
348365 ] , [ ] ) ;
349366
350367 return (
351- < div class = "mx-auto bg-none rounded-lg" >
352-
353-
354-
355-
356- { sortedAndPaginatedData . currentItems . length > 0 && (
368+ < div className = "mx-auto bg-none rounded-lg" >
369+ < Notification
370+ show = { notification . show }
371+ setShow = { ( show ) => setNotification ( { ...notification , show } ) }
372+ message = { notification . message }
373+ />
374+ { sortedAndPaginatedData . currentItems . length > 0 && isAuthenticated && (
357375 < div className = "mx-auto w-full mb-10 min-h-fit" >
358376 < div >
359377 < div className = "w-full -mt-5" >
360- < div className = "w-fit mx-auto" >
361- < YugiohPagination
362- currentPage = { currentPage }
363- itemsPerPage = { itemsPerPage }
364- totalItems = { sortedAndPaginatedData . totalCount }
365- handlePageClick = { setCurrentPage }
366- />
367- </ div >
378+
379+
368380 < div className = "max-h-fit w-full mt-4 flex flex-wrap justify-center gap-3" >
369381 < button
370382 type = "button"
@@ -389,7 +401,6 @@ const YugiohCardDataTable = ( {
389401 </ button >
390402 </ div >
391403
392-
393404 { selectedKeys . size > 0 && (
394405 < div className = "flex flex-wrap items-center justify-between gap-3 border-b border-white/5 px-4 py-3 text-sm text-indigo-100" >
395406 < div >
@@ -401,8 +412,15 @@ const YugiohCardDataTable = ( {
401412 </ div >
402413 </ div >
403414 ) }
404-
405415 < div className = "overflow-x-auto" >
416+ < div className = "w-fit mx-auto" >
417+ < YugiohPagination
418+ currentPage = { currentPage }
419+ itemsPerPage = { itemsPerPage }
420+ totalItems = { sortedAndPaginatedData . totalCount }
421+ handlePageClick = { setCurrentPage }
422+ />
423+ </ div >
406424 < table className = "glass min-w-full text-sm text-white mt-10" >
407425 < thead >
408426 < tr className = "bg-white/5 text-xs uppercase tracking-wide text-white/80" >
@@ -495,11 +513,7 @@ const YugiohCardDataTable = ( {
495513 </ div >
496514 </ div >
497515 </ div >
498- < Notification
499- show = { notification . show }
500- setShow = { ( show ) => setNotification ( { ...notification , show } ) }
501- message = { notification . message }
502- />
516+
503517 </ div >
504518 ) }
505519 </ div >
0 commit comments