| @@ -20,6 +20,7 @@ import { | |||||
| FormHelperText, | FormHelperText, | ||||
| TextField, | TextField, | ||||
| IconButton, InputAdornment, | IconButton, InputAdornment, | ||||
| CircularProgress, | |||||
| } from '@mui/material'; | } from '@mui/material'; | ||||
| import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
| @@ -48,7 +49,9 @@ const Index = () => { | |||||
| const [verifyState, setVerifyState] = React.useState(null) | const [verifyState, setVerifyState] = React.useState(null) | ||||
| const [enterUseEffect, setEnterUseEffect] = React.useState(false) | const [enterUseEffect, setEnterUseEffect] = React.useState(false) | ||||
| const [username, setUsername] = React.useState("") | const [username, setUsername] = React.useState("") | ||||
| const [isSubmitting, setIsSubmitting] = React.useState(false) | |||||
| const submittingRef = React.useRef(false) | |||||
| const params = useParams() | const params = useParams() | ||||
| const intl = useIntl(); | const intl = useIntl(); | ||||
| @@ -94,6 +97,9 @@ const Index = () => { | |||||
| } | } | ||||
| const goLogin = async (values) =>{ | const goLogin = async (values) =>{ | ||||
| if (submittingRef.current) return; | |||||
| submittingRef.current = true; | |||||
| setIsSubmitting(true); | |||||
| dispatch(handleLogoutFunction()); | dispatch(handleLogoutFunction()); | ||||
| HttpUtils.post({ | HttpUtils.post({ | ||||
| url: UrlUtils.POST_FORGOT_PASSWORD_NEW_PASSWORD, | url: UrlUtils.POST_FORGOT_PASSWORD_NEW_PASSWORD, | ||||
| @@ -110,19 +116,24 @@ const Index = () => { | |||||
| // console.log(response) | // console.log(response) | ||||
| navigate('/forgot/password/success'); | navigate('/forgot/password/success'); | ||||
| location.reload() | location.reload() | ||||
| // setSumitting(false) | |||||
| }) | }) | ||||
| .catch((error) => { | .catch((error) => { | ||||
| console.error(error) | console.error(error) | ||||
| submittingRef.current = false; | |||||
| setIsSubmitting(false); | |||||
| }); | }); | ||||
| }, | }, | ||||
| onFail: (response)=>{ | onFail: (response)=>{ | ||||
| console.log("Fail"); | console.log("Fail"); | ||||
| console.log(response); | console.log(response); | ||||
| submittingRef.current = false; | |||||
| setIsSubmitting(false); | |||||
| window.location.assign("/iamsmart/loginFail"); | window.location.assign("/iamsmart/loginFail"); | ||||
| }, | }, | ||||
| onError:(error)=>{ | onError:(error)=>{ | ||||
| console.log(error); | console.log(error); | ||||
| submittingRef.current = false; | |||||
| setIsSubmitting(false); | |||||
| window.location.assign("/iamsmart/loginFail"); | window.location.assign("/iamsmart/loginFail"); | ||||
| } | } | ||||
| }); | }); | ||||
| @@ -384,9 +395,10 @@ const Index = () => { | |||||
| aria-label={intl.formatMessage({id: 'confirm'})} | aria-label={intl.formatMessage({id: 'confirm'})} | ||||
| variant="contained" | variant="contained" | ||||
| type="submit" | type="submit" | ||||
| // onClick={()=>goLogin()} | |||||
| disabled={isSubmitting} | |||||
| startIcon={isSubmitting ? <CircularProgress color="inherit" size={20} /> : null} | |||||
| > | > | ||||
| <FormattedMessage id="confirm"/> | |||||
| {isSubmitting ? <FormattedMessage id="loading"/> : <FormattedMessage id="confirm"/>} | |||||
| </Button> | </Button> | ||||
| </ThemeProvider> | </ThemeProvider> | ||||
| </Grid> | </Grid> | ||||