@@ -20,7 +20,7 @@ export default function Profile() {
2020 const [ loading , setLoading ] = useState ( true ) ; // NEW
2121
2222 useEffect ( ( ) => {
23- chrome . storage . local . get ( [ "idToken" , "accessToken" ] , ( result ) => {
23+ chrome . storage . local . get ( [ "idToken" , "accessToken" , "notes" ] , ( result ) => {
2424 if ( result . idToken && result . accessToken ) {
2525 const user = UserPool . getCurrentUser ( ) ;
2626 if ( user ) {
@@ -32,10 +32,17 @@ export default function Profile() {
3232 attrs . forEach ( ( attr ) => {
3333 profile [ attr . getName ( ) ] = attr . getValue ( ) ;
3434 } ) ;
35+ profile . fullName = profile . name || `${ profile . given_name || "" } ${ profile . family_name || "" } ` ;
36+ profile . email = profile . email || session . getIdToken ( ) . payload . email ;
37+ profile . totalNotes = result . notes
38+ ? result . notes . filter ( ( note ) => ! note . deleted ) . length
39+ : 0 ;
40+
41+
3542 setProfileData ( profile ) ;
3643 setIsLoggedIn ( true ) ;
3744 }
38- setLoading ( false ) ; // ✅ done checking
45+ setLoading ( false ) ;
3946 } ) ;
4047 } else {
4148 setLoading ( false ) ;
@@ -206,15 +213,39 @@ export default function Profile() {
206213 }
207214
208215 if ( isLoggedIn && profileData ) {
209- return (
210- < div >
211- < h2 > Welcome, { profileData . name || profileData . email } </ h2 >
212- < p > Email: { profileData . email } </ p >
213- < button
214- id = "save-btn"
215- className = "btn btn-sm rounded-pill px-3 text-white"
216- onClick = { handleSignOut }
217- > Sign Out</ button >
216+ return (
217+ < div className = "container py-4" >
218+ < div className = "card shadow-sm p-4" >
219+ < div className = "row align-items-start" >
220+ < div className = "col-12 col-md-2 text-center" >
221+ < i
222+ className = "fas fa-user-circle"
223+ style = { { fontSize : "150px" , color : "#555" } }
224+ > </ i >
225+ </ div >
226+
227+ < div className = "col-12 col-md-10" >
228+ < p > Full Name: { profileData . fullName } </ p >
229+ < p > Email: { profileData . email } </ p >
230+ </ div >
231+ </ div >
232+ < br />
233+ < hr />
234+ < br />
235+ < div >
236+ < h5 className = "mb-3" > Notes</ h5 >
237+ Total Notes: < strong > { profileData . totalNotes || 0 } </ strong >
238+ </ div >
239+
240+ < div className = "mt-4 text-end" >
241+ < button
242+ className = "btn btn-sm btn-danger rounded-pill px-4"
243+ onClick = { handleSignOut }
244+ >
245+ Sign Out
246+ </ button >
247+ </ div >
248+ </ div >
218249 </ div >
219250 ) ;
220251 }
@@ -242,7 +273,7 @@ export default function Profile() {
242273
243274 return (
244275 < div
245- className = { `container ${ ! isSigningIn ? "right-panel-active" : "" } ` }
276+ className = { `container pt-5 ${ ! isSigningIn ? "right-panel-active" : "" } ` }
246277 id = "profile-container"
247278 >
248279 < div class = "form-container sign-up-container" >
0 commit comments