@@ -9,6 +9,7 @@ import { backend_get, deleteAuthCookies } from "../../utils";
9
9
import { useNavigate , useParams } from "react-router-dom" ;
10
10
import { JwtPayload , jwtDecode } from "jwt-decode" ;
11
11
import { CookieJWT } from "../../types/common" ;
12
+ import { Button , capitalize } from "@mui/material" ;
12
13
13
14
const Profile = ( ) => {
14
15
const navigate = useNavigate ( ) ;
@@ -20,7 +21,7 @@ const Profile = () => {
20
21
role : "" ,
21
22
first_name : "" ,
22
23
last_name : "" ,
23
- avatarUrl : "https://randomuser.me/api/portraits/men/5.jpg "
24
+ avatarUrl : ""
24
25
} ) ;
25
26
26
27
const getProfileData = async ( ) => {
@@ -37,6 +38,17 @@ const Profile = () => {
37
38
const resp = await backend_get ( "user/get/" + username , true ) ;
38
39
return resp . json ( ) ;
39
40
} ;
41
+
42
+ const updateProfilePicture = async ( ) => {
43
+ console . log ( 'Update Profile Picture function triggered' ) ;
44
+ } ;
45
+
46
+ // const [loggedInUsername, setLoggedInUsername] = useState("");
47
+ //store image inside a storage solution (S3 bucket)!
48
+ // After, we collect the url from the s3
49
+ // store url in database
50
+ // it will be retrieved in getprofile data via url
51
+ // 1 image per profile, therefore, override the previous one
40
52
41
53
useEffect ( ( ) => {
42
54
const fetchUserProfile = async ( ) => {
@@ -48,8 +60,7 @@ const Profile = () => {
48
60
navigate ( 0 ) ;
49
61
return ;
50
62
}
51
- // profile[0]["avaterUrl"] =
52
- // "https://randomuser.me/api/portraits/men/5.jpg";
63
+ profile [ "avatarUrl" ] = "https://randomuser.me/api/portraits/men/5.jpg" ;
53
64
setProfileData ( profile ) ;
54
65
} catch ( error ) {
55
66
console . error ( "Error fetching profile:" , error ) ;
@@ -69,20 +80,30 @@ const Profile = () => {
69
80
src = { profileData . avatarUrl }
70
81
alt = "User Avatar"
71
82
/>
83
+
84
+
72
85
< div className = "profile-info" >
73
86
< Typography component = "h1" variant = "h5" >
74
87
{ profileData . first_name } { profileData . last_name }
75
88
</ Typography >
76
- < Typography component = "p" variant = "body1" >
77
- Username: { profileData . username }
78
- </ Typography >
79
- < Typography component = "p" variant = "body1" >
80
- Email: { profileData . email }
81
- </ Typography >
82
- < Typography component = "p" variant = "body1" >
83
- Role: { profileData . role }
84
- </ Typography >
89
+ < p > < span className = "label" > Username:</ span > { profileData . username } </ p >
90
+ < p > < span className = "label" > Email:</ span > { profileData . email } </ p >
91
+ < p > < span className = "label" > Role:</ span > { capitalize ( profileData . role ) } </ p >
92
+ </ div >
93
+
94
+ < div style = { { marginTop :"3%" } } >
95
+ < Button variant = "contained" sx = { { textTransform :"none" } } >
96
+ Change Picture
97
+ </ Button >
98
+ < Button variant = "contained" sx = { { textTransform :"none" } } >
99
+ Change Password
100
+ </ Button >
85
101
</ div >
102
+
103
+ < Button variant = "contained" sx = { { marginTop :"3%" , textTransform :"none" } } >
104
+ Log Out
105
+ </ Button >
106
+
86
107
</ div >
87
108
</ Container >
88
109
</ RootPage >
0 commit comments