diff --git a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js index a92a0d2..33763bd 100644 --- a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js +++ b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js @@ -34,6 +34,7 @@ import {FormattedMessage, useIntl} from "react-intl"; const ForgotPasswordApplyForm = () => { const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [isSubmitting, setIsSubmitting] = React.useState(false); + const submittingRef = React.useRef(false); // const [warningText, setWarningText] = React.useState("");s // const [attachment, setAttachment] = React.useState({}); const intl = useIntl(); @@ -60,7 +61,8 @@ const ForgotPasswordApplyForm = () => { username: yup.string().required(intl.formatMessage({id: 'requireUsername'})), }), onSubmit: values => { - if (isSubmitting) return; + if (submittingRef.current) return; + submittingRef.current = true; // console.log(values) setIsSubmitting(true); HttpUtils.post({ @@ -70,12 +72,14 @@ const ForgotPasswordApplyForm = () => { }, // files: [attachment], onSuccess: function () { + submittingRef.current = false; setIsSubmitting(false); // notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') navigate('/forgot/password/sent'); // location.reload(); }, onError: function () { + submittingRef.current = false; setIsSubmitting(false); navigate('/forgot/password/sent'); } diff --git a/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js b/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js index 9d8981d..d0ce65e 100644 --- a/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js +++ b/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js @@ -34,6 +34,7 @@ import {FormattedMessage, useIntl} from "react-intl"; const ForgotUsernameApplyForm = () => { const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [isSubmitting, setIsSubmitting] = React.useState(false); + const submittingRef = React.useRef(false); // const [warningText, setWarningText] = React.useState("");s // const [attachment, setAttachment] = React.useState({}); const intl = useIntl(); @@ -62,7 +63,8 @@ const ForgotUsernameApplyForm = () => { emailAddress: yup.string().email(intl.formatMessage({id: 'validEmailFormat'})).max(255).required(intl.formatMessage({id: 'requireEmail'})), }), onSubmit: values => { - if (isSubmitting) return; + if (submittingRef.current) return; + submittingRef.current = true; // console.log(values) setIsSubmitting(true); HttpUtils.post({ @@ -72,12 +74,14 @@ const ForgotUsernameApplyForm = () => { }, // files: [attachment], onSuccess: function () { + submittingRef.current = false; setIsSubmitting(false); // notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') navigate('/forgot/username/sent'); // location.reload(); }, onError: function () { + submittingRef.current = false; setIsSubmitting(false); navigate('/forgot/username/sent'); }