@@ -21,6 +21,7 @@ import {
2121} from "lucide-react" ;
2222import Image from "next/image" ;
2323import { getAssetPath } from "@/lib/utils" ;
24+ import type { User } from '@vector-institute/aieng-auth-core' ;
2425
2526// Types
2627interface RepoSnapshot {
@@ -113,7 +114,11 @@ type SortDirection = "asc" | "desc";
113114type ActiveTab = "github" | "pypi" ;
114115type PyPIFilter = "all" | "tool" | "bootcamp" | "applied-research" ;
115116
116- export default function AnalyticsPage ( ) {
117+ interface AnalyticsPageProps {
118+ user : User | null ;
119+ }
120+
121+ export default function AnalyticsPage ( { user } : AnalyticsPageProps ) {
117122 // Load data dynamically to ensure fresh data during development
118123 const [ historicalData , setHistoricalData ] = useState < HistoricalData | null > ( null ) ;
119124 const [ pypiData , setPypiData ] = useState < PyPIHistoricalData | null > ( null ) ;
@@ -126,6 +131,15 @@ export default function AnalyticsPage() {
126131 const [ activeTab , setActiveTab ] = useState < ActiveTab > ( "github" ) ;
127132 const [ pypiFilter , setPypiFilter ] = useState < PyPIFilter > ( "all" ) ;
128133
134+ const handleLogout = async ( ) => {
135+ try {
136+ await fetch ( '/analytics/api/auth/logout' , { method : 'POST' } ) ;
137+ window . location . href = '/analytics/login' ;
138+ } catch ( error ) {
139+ console . error ( 'Logout failed:' , error ) ;
140+ }
141+ } ;
142+
129143 useEffect ( ( ) => {
130144 const loadData = async ( ) => {
131145 try {
@@ -437,21 +451,35 @@ export default function AnalyticsPage() {
437451 </ p >
438452 </ div >
439453 </ div >
440- { historicalData ?. last_updated && (
441- < div className = "hidden md:flex items-center gap-2 text-white/90" >
442- < Calendar className = "w-5 h-5" />
443- < div className = "text-right" >
444- < div className = "text-xs uppercase tracking-wide opacity-80" >
445- Last Updated
446- </ div >
447- < div className = "text-sm font-medium" >
448- { new Date ( historicalData . last_updated )
449- . toISOString ( )
450- . split ( "T" ) [ 0 ] }
454+ < div className = "flex items-center gap-4" >
455+ { historicalData ?. last_updated && (
456+ < div className = "hidden lg:flex items-center gap-2 text-white/90" >
457+ < Calendar className = "w-5 h-5" />
458+ < div className = "text-right" >
459+ < div className = "text-xs uppercase tracking-wide opacity-80" >
460+ Last Updated
461+ </ div >
462+ < div className = "text-sm font-medium" >
463+ { new Date ( historicalData . last_updated )
464+ . toISOString ( )
465+ . split ( "T" ) [ 0 ] }
466+ </ div >
451467 </ div >
452468 </ div >
453- </ div >
454- ) }
469+ ) }
470+ { user && (
471+ < div className = "text-right" >
472+ < p className = "text-xs text-white/70 uppercase tracking-wide" > Signed in as</ p >
473+ < p className = "text-sm font-semibold bg-gradient-to-r from-vector-magenta to-vector-violet bg-clip-text text-transparent" > { user . email } </ p >
474+ </ div >
475+ ) }
476+ < button
477+ onClick = { handleLogout }
478+ className = "px-4 py-2 text-sm font-semibold text-white bg-gradient-to-r from-slate-600 to-slate-700 hover:from-vector-magenta hover:to-vector-violet rounded-lg shadow-sm hover:shadow-md transition-all duration-200"
479+ >
480+ Logout
481+ </ button >
482+ </ div >
455483 </ motion . div >
456484 </ div >
457485 </ div >
0 commit comments