1+ 'use client' ;
2+
3+ import { useSession } from 'next-auth/react' ;
4+ import Image from 'next/image' ;
5+ import Link from 'next/link' ;
6+ import { Tabs } from 'antd' ;
7+ import { useState } from 'react' ;
8+
9+ export default function ProfilePage ( ) {
10+ const { data : session } = useSession ( ) ;
11+ const [ activeTab , setActiveTab ] = useState ( '1' ) ;
12+
13+ if ( ! session ) {
14+ return (
15+ < div className = "min-h-screen bg-gray-100 flex items-center justify-center" >
16+ < div className = "text-center" >
17+ < h1 className = "text-2xl font-bold text-gray-800" > Please login first</ h1 >
18+ </ div >
19+ </ div >
20+ ) ;
21+ }
22+
23+ return (
24+ < div className = "min-h-screen bg-gray-100" >
25+ { /* Top bar: Return Home button on the left, Profile Info on the right */ }
26+ < header className = "bg-white border-b" >
27+ < div className = "max-w-6xl mx-auto flex justify-between items-center px-4 py-6" >
28+ { /* Left: Return Home Button */ }
29+ < div >
30+ < Link href = "/" >
31+ < button className = "px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-200" >
32+ Return Home
33+ </ button >
34+ </ Link >
35+ </ div >
36+ { /* Right: Profile Info */ }
37+ < div className = "flex items-center space-x-6" >
38+ < div className = "relative" >
39+ < Image
40+ src = { session . user ?. image || '/default-avatar.png' }
41+ alt = "Profile"
42+ width = { 100 }
43+ height = { 100 }
44+ className = "rounded-full"
45+ />
46+ </ div >
47+ < div >
48+ < h1 className = "text-2xl font-bold mb-1" > { session . user ?. name } </ h1 >
49+ < p className = "text-gray-600 mb-2" > { session . user ?. email } </ p >
50+ < button className = "px-4 py-2 bg-gray-100 rounded-md hover:bg-gray-200" >
51+ Edit Profile
52+ </ button >
53+ </ div >
54+ </ div >
55+ </ div >
56+ </ header >
57+
58+ { /* Main Content Area (Tabs) */ }
59+ < div className = "max-w-6xl mx-auto px-4 py-6" >
60+ < Tabs
61+ activeKey = { activeTab }
62+ onChange = { setActiveTab }
63+ items = { [
64+ {
65+ key : '1' ,
66+ label : 'Overview' ,
67+ children : < OverviewTab /> ,
68+ } ,
69+ {
70+ key : '2' ,
71+ label : 'My Favorites' ,
72+ children : < FavoritesTab /> ,
73+ } ,
74+ {
75+ key : '3' ,
76+ label : 'Uploads' ,
77+ children : < UploadsTab /> ,
78+ } ,
79+ {
80+ key : '4' ,
81+ label : 'Analysis History' ,
82+ children : < AnalysisHistoryTab /> ,
83+ } ,
84+ ] }
85+ />
86+ </ div >
87+ </ div >
88+ ) ;
89+ }
90+
91+ // Overview Tab component
92+ function OverviewTab ( ) {
93+ return (
94+ < div className = "grid grid-cols-1 md:grid-cols-2 gap-6" >
95+ { /* Activity Stats */ }
96+ < div className = "bg-white p-6 rounded-lg shadow" >
97+ < h3 className = "text-lg font-semibold mb-4" > Activity Stats</ h3 >
98+ < div className = "space-y-4" >
99+ < div className = "flex justify-between" >
100+ < span > Analysis Count</ span >
101+ < span className = "font-semibold" > 123</ span >
102+ </ div >
103+ < div className = "flex justify-between" >
104+ < span > Favorites Count</ span >
105+ < span className = "font-semibold" > 45</ span >
106+ </ div >
107+ < div className = "flex justify-between" >
108+ < span > Crate Uploads</ span >
109+ < span className = "font-semibold" > 12</ span >
110+ </ div >
111+ </ div >
112+ </ div >
113+
114+ { /* Recent Activity */ }
115+ < div className = "bg-white p-6 rounded-lg shadow" >
116+ < h3 className = "text-lg font-semibold mb-4" > Recent Activity</ h3 >
117+ < div className = "space-y-4" >
118+ < div className = "flex items-center space-x-3" >
119+ < div className = "flex-1" >
120+ < p className = "text-sm" > Analyzed tokio crate</ p >
121+ < p className = "text-xs text-gray-500" > 2 hours ago</ p >
122+ </ div >
123+ </ div >
124+ < div className = "flex items-center space-x-3" >
125+ < div className = "flex-1" >
126+ < p className = "text-sm" > Favorited serde crate</ p >
127+ < p className = "text-xs text-gray-500" > 1 day ago</ p >
128+ </ div >
129+ </ div >
130+ </ div >
131+ </ div >
132+ </ div >
133+ ) ;
134+ }
135+
136+ // My Favorites Tab component
137+ function FavoritesTab ( ) {
138+ return (
139+ < div className = "space-y-4" >
140+ < div className = "bg-white p-6 rounded-lg shadow" >
141+ < h3 className = "text-lg font-semibold mb-4" > My Favorites</ h3 >
142+ { /* Favorites list */ }
143+ < div className = "space-y-4" >
144+ { /* Sample favorite item */ }
145+ < div className = "border-b pb-4" >
146+ < div className = "flex justify-between items-start" >
147+ < div >
148+ < h4 className = "text-lg font-medium" > serde</ h4 >
149+ < p className = "text-sm text-gray-600" >
150+ A generic serialization/deserialization framework
151+ </ p >
152+ </ div >
153+ < button className = "text-red-500 hover:text-red-600" >
154+ Unfavorite
155+ </ button >
156+ </ div >
157+ </ div >
158+ { /* More favorite items... */ }
159+ </ div >
160+ </ div >
161+ </ div >
162+ ) ;
163+ }
164+
165+ // Uploads Tab component
166+ function UploadsTab ( ) {
167+ return (
168+ < div className = "space-y-4" >
169+ < div className = "bg-white p-6 rounded-lg shadow" >
170+ < h3 className = "text-lg font-semibold mb-4" > Uploads</ h3 >
171+ { /* Uploads list */ }
172+ < div className = "space-y-4" >
173+ { /* Sample upload item */ }
174+ < div className = "border-b pb-4" >
175+ < div className = "flex justify-between items-start" >
176+ < div >
177+ < h4 className = "text-lg font-medium" > my-crate</ h4 >
178+ < p className = "text-sm text-gray-600" > Upload Time: 2024-03-20</ p >
179+ </ div >
180+ < button className = "text-blue-500 hover:text-blue-600" >
181+ View Analysis
182+ </ button >
183+ </ div >
184+ </ div >
185+ { /* More upload items... */ }
186+ </ div >
187+ </ div >
188+ </ div >
189+ ) ;
190+ }
191+
192+ // Analysis History Tab component
193+ function AnalysisHistoryTab ( ) {
194+ return (
195+ < div className = "space-y-4" >
196+ < div className = "bg-white p-6 rounded-lg shadow" >
197+ < h3 className = "text-lg font-semibold mb-4" > Analysis History</ h3 >
198+ { /* Analysis history list */ }
199+ < div className = "space-y-4" >
200+ { /* Sample analysis item */ }
201+ < div className = "border-b pb-4" >
202+ < div className = "flex justify-between items-start" >
203+ < div >
204+ < h4 className = "text-lg font-medium" > tokio (v1.36.0)</ h4 >
205+ < p className = "text-sm text-gray-600" > Analysis Time: 2024-03-21</ p >
206+ </ div >
207+ < button className = "text-blue-500 hover:text-blue-600" >
208+ View Report
209+ </ button >
210+ </ div >
211+ </ div >
212+ { /* More analysis items... */ }
213+ </ div >
214+ </ div >
215+ </ div >
216+ ) ;
217+ }
0 commit comments