@@ -3,7 +3,7 @@ import axios, { AxiosRequestConfig } from 'axios';
33import * as settings from '../../settings' ;
44
55import { makeStyles } from '@material-ui/core/styles' ;
6- import { Avatar , Button , Container , CssBaseline , TextField , Typography } from '@material-ui/core' ;
6+ import { Avatar , Button , Container , CssBaseline , LinearProgress , TextField , Typography } from '@material-ui/core' ;
77import VpnKeyIcon from '@material-ui/icons/VpnKey' ;
88import { AuthProps } from '../../App' ;
99import { PasswordUpdateError } from '../../interfaces/axios/AxiosError' ;
@@ -39,6 +39,7 @@ function PasswordUpdate(props: AuthProps) {
3939 const [ new_password2 , setNewPassword2 ] = useState ( "" ) ;
4040 const [ success , setSuccess ] = useState ( false ) ;
4141 const [ validationErrors , setValidationErrors ] = useState < string [ ] > ( [ ] )
42+ const [ isLoading , setIsLoading ] = useState ( false )
4243
4344 const handleFormFieldChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
4445 setSuccess ( false ) ;
@@ -52,6 +53,7 @@ function PasswordUpdate(props: AuthProps) {
5253
5354 const handleSubmit = ( e : React . ChangeEvent < HTMLFormElement > ) => {
5455 e . preventDefault ( ) ;
56+ setIsLoading ( true )
5557 if ( new_password1 !== new_password2 ) {
5658 setValidationErrors ( [ "Passwords don't match!" ] )
5759 } else if ( new_password1 === "" ) {
@@ -72,6 +74,7 @@ function PasswordUpdate(props: AuthProps) {
7274 ( error : PasswordUpdateError ) => {
7375 console . log ( error . response . data . new_password2 )
7476 setValidationErrors ( error . response . data . new_password2 )
77+ setIsLoading ( false )
7578 } )
7679 }
7780 }
@@ -88,7 +91,7 @@ function PasswordUpdate(props: AuthProps) {
8891 < >
8992 < Typography component = "h1" variant = "h5" >
9093 Update Password
91- </ Typography >
94+ </ Typography >
9295 < form className = { classes . form } noValidate onSubmit = { handleSubmit } >
9396 < TextField
9497 variant = "outlined"
@@ -117,6 +120,7 @@ function PasswordUpdate(props: AuthProps) {
117120 helperText = { new_password1 !== new_password2 ? "Passwords don't match" : null }
118121 />
119122 { validationErrorMessages ( validationErrors ) }
123+ { isLoading && < LinearProgress color = "secondary" /> }
120124 < Button
121125 type = "submit"
122126 fullWidth
@@ -133,7 +137,7 @@ function PasswordUpdate(props: AuthProps) {
133137 variant = "contained"
134138 color = "primary"
135139 href = "/" > Return Home
136- </ Button >
140+ </ Button >
137141 }
138142 </ div >
139143 </ Container >
0 commit comments