File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1- import { useEffect } from "react" ;
1+ import { useEffect , useState } from "react" ;
22import { Header } from "../components/Common/Common" ;
33import { OAUTH_LOGIN_URL , useAuthContext } from "../utils/auth" ;
4+ import { makeRequest } from "../utils/backend" ;
45
56function MainPage ( ) {
67 const auth = useAuthContext ( ) ;
8+ const [ subtitle , setSubtitle ] = useState < string | null > ( null ) ;
9+
10+ const fetchProfile = async ( ) => {
11+ const response = await makeRequest ( 'profile' , 'post' ) ;
12+
13+ if ( response . status == 'success' ) {
14+ setSubtitle ( `Welcome, ${ response . data . username } ` ) ;
15+ } else {
16+ setSubtitle ( "Error loading profile (username)." ) ;
17+ }
18+ }
719
820 useEffect ( ( ) => {
921 if ( ! auth . isAuthenticated ) {
1022 window . location . assign ( OAUTH_LOGIN_URL ) ;
23+ } else {
24+ fetchProfile ( ) ;
1125 }
1226 } , [ ] ) ;
1327
1428 return < >
1529 < Header
1630 title = "MetaKGP Maintainers' Dashboard"
31+ subtitle = { subtitle ?? undefined }
1732 />
1833 </ > ;
1934}
You can’t perform that action at this time.
0 commit comments