@@ -17,15 +17,19 @@ const ProfileSection = () => {
1717
1818 const handleSubmit = async ( event ) => {
1919 event . preventDefault ( ) ;
20- if ( isUpdating ) return ;
21- setIsUpdating ( true ) ;
20+
21+ console . log ( nameRef . current . value ) ;
22+
2223 const formData = new FormData ( ) ;
24+
2325 if ( profilePictureRef . current . files [ 0 ] ) { formData . append ( 'profilePicture' , profilePictureRef . current . files [ 0 ] ) ; }
2426 formData . append ( 'name' , nameRef . current . value ) ;
2527 formData . append ( 'bio' , bioRef . current . value ) ;
28+
29+
2630 const res = await fetch ( '/api/user' , {
2731 method : 'PATCH' ,
28- body : formData ,
32+ body :formData ,
2933 } ) ;
3034 if ( res . status === 200 ) {
3135 const userData = await res . json ( ) ;
@@ -63,12 +67,6 @@ const ProfileSection = () => {
6367 }
6468 } ;
6569
66- async function sendVerificationEmail ( ) {
67- await fetch ( '/api/user/email/verify' , {
68- method : 'POST' ,
69- } ) ;
70- }
71-
7270 return (
7371 < >
7472 < Head >
@@ -78,17 +76,6 @@ const ProfileSection = () => {
7876 < h2 > Edit Profile</ h2 >
7977 { msg . message ? < p style = { { color : msg . isError ? 'red' : '#0070f3' , textAlign : 'center' } } > { msg . message } </ p > : null }
8078 < form onSubmit = { handleSubmit } className = "col s12" >
81- { ! user . emailVerified ? (
82- < p >
83- Your email has not been verify.
84- { ' ' }
85- { /* eslint-disable-next-line */ }
86- < a role = "button" className = "blue-text" onClick = { sendVerificationEmail } >
87- Send verification email
88- </ a >
89- </ p >
90- ) : null }
91-
9279 < div className = "divider" > </ div >
9380 < label htmlFor = "name" className = "input-field col s6" >
9481 Name
@@ -113,8 +100,8 @@ const ProfileSection = () => {
113100 />
114101 </ label >
115102 < label htmlFor = "avatar" >
116- < span > Profile picture </ span >
117- < div className = "btn-small file-field input-field blue" >
103+ < span > Profile picture </ span >
104+ < div className = "btn-small file-field input-field blue" >
118105 < span > Choose file</ span >
119106 < input
120107 type = "file"
@@ -126,7 +113,7 @@ const ProfileSection = () => {
126113 </ div >
127114 </ label >
128115 < br />
129- < button disabled = { isUpdating } type = "submit" className = "btn blue" > Save</ button >
116+ < button type = "submit" className = "btn blue" > Save</ button >
130117 </ form >
131118 < form onSubmit = { handleSubmitPasswordChange } >
132119 < label htmlFor = "oldpassword" >
0 commit comments