浏览代码

avoid double click from changing password form

web_access_fix
Jason Chuang 21 小时前
父节点
当前提交
40dd3d56ec
共有 1 个文件被更改,包括 15 次插入4 次删除
  1. +15
    -4
      src/pages/User/ChangePasswordPage/index.js

+ 15
- 4
src/pages/User/ChangePasswordPage/index.js 查看文件

@@ -51,6 +51,8 @@ const Index = () => {
const [expiryErr, setExpiryErr] = React.useState(false);
const [expiryErrText, setExpiryErrText] = React.useState("");
const [changePasswordValues, setChangePasswordValues] = React.useState();
const [isChangingPassword, setIsChangingPassword] = React.useState(false);
const changePwdInFlightRef = React.useRef(false);

const intl = useIntl();
@@ -59,8 +61,12 @@ const Index = () => {
}, []);

const goLogin = (values) =>{
// console.log(values)
setComfirmChangeMessage(false)
if (changePwdInFlightRef.current) {
return;
}
changePwdInFlightRef.current = true;
setIsChangingPassword(true);
setComfirmChangeMessage(false);
HttpUtils.post({
url: UrlUtils.PATCH_CHANGE_PASSWORD,
params:{
@@ -69,11 +75,15 @@ const Index = () => {
},
onSuccess: function (){
setIsChanged(true);
changePwdInFlightRef.current = false;
setIsChangingPassword(false);
},
onError:function (error) {
// console.log(error.response.data);
setExpiryErrText(intl.formatMessage({ id: error.response.data.error }))
setExpiryErr(true)
changePwdInFlightRef.current = false;
setIsChangingPassword(false);
// window.location.assign("/iamsmart/loginFail");
}
});
@@ -395,6 +405,7 @@ const Index = () => {
aria-label={intl.formatMessage({id: 'confirm'})}
variant="contained"
type="submit"
disabled={isChangingPassword}
// onClick={()=>goLogin()}
>
<FormattedMessage id="confirm"/>
@@ -423,12 +434,12 @@ const Index = () => {
</Stack>
</DialogContent>
<DialogActions>
<Button onClick={() => setComfirmChangeMessage(false)}>
<Button disabled={isChangingPassword} onClick={() => setComfirmChangeMessage(false)}>
<Typography variant="h5">
<FormattedMessage id="close"/>
</Typography>
</Button>
<Button onClick={() => goLogin(changePasswordValues)}>
<Button disabled={isChangingPassword} onClick={() => goLogin(changePasswordValues)}>
<Typography variant="h5">
<FormattedMessage id="confirm"/>
</Typography>


正在加载...
取消
保存