diff --git a/src/pages/Proof/Reply_Public/ProofForm.js b/src/pages/Proof/Reply_Public/ProofForm.js index 11d2b0f..5226f37 100644 --- a/src/pages/Proof/Reply_Public/ProofForm.js +++ b/src/pages/Proof/Reply_Public/ProofForm.js @@ -51,6 +51,7 @@ const FormPanel = ({ formData }) => { const [warningTitle, setWarningTitle] = React.useState(""); const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [warningText, setWarningText] = React.useState(""); + const [isSubmitting, setIsSubmitting] = React.useState(false); const [isOnlyOnlinePayment, setOnlyOnlinePayment] = React.useState(); const [isNoPayment, setNoPayment] = React.useState(); @@ -87,6 +88,7 @@ const FormPanel = ({ formData }) => { vaild: yup.string().max(255, intl.formatMessage({ id: 'requireLoginPassword' })).required(intl.formatMessage({ id: 'requireLoginPassword' })), }), onSubmit: values => { + if (isSubmitting) return; if (isOverTime() && !isDummyLoggedIn()) { setWarningTitle(intl.formatMessage({ id: "attention" })) setWarningText(intl.formatMessage({ id: 'MSG.proofOutOfTime' })); @@ -124,6 +126,7 @@ const FormPanel = ({ formData }) => { } } // console.log(values); + setIsSubmitting(true); HttpUtils.postWithFiles({ url: UrlUtils.REPLY_PROOF, params: { @@ -134,8 +137,15 @@ const FormPanel = ({ formData }) => { }, files: attachments ? attachments : [], onSuccess: function (responseData) { + setIsSubmitting(false); // console.log(responseData) if (responseData.success === false) { + if (responseData.msg) { + setWarningTitle(intl.formatMessage({ id: "attention" })) + setWarningText(intl.formatMessage({ id: responseData.msg })); + setIsWarningPopUp(true); + return; + } navigate("/publicNotice/" + responseData.id); } else { if (responseData.msg) { @@ -153,12 +163,14 @@ const FormPanel = ({ formData }) => { } }, onFail: function (response) { + setIsSubmitting(false); setWarningTitle(intl.formatMessage({ id: "attention" })) setWarningText(intl.formatMessage({ id: 'actionFail' })); setIsWarningPopUp(true); console.log(response); }, onError: function (error) { + setIsSubmitting(false); setWarningTitle(intl.formatMessage({ id: "attention" })) setWarningText(intl.formatMessage({ id: 'actionFail' })); setIsWarningPopUp(true); @@ -688,7 +700,7 @@ const FormPanel = ({ formData }) => { diff --git a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js index c08ef4b..a92a0d2 100644 --- a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js +++ b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js @@ -33,6 +33,7 @@ import {FormattedMessage, useIntl} from "react-intl"; const ForgotPasswordApplyForm = () => { const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); + const [isSubmitting, setIsSubmitting] = React.useState(false); // const [warningText, setWarningText] = React.useState("");s // const [attachment, setAttachment] = React.useState({}); const intl = useIntl(); @@ -59,7 +60,9 @@ const ForgotPasswordApplyForm = () => { username: yup.string().required(intl.formatMessage({id: 'requireUsername'})), }), onSubmit: values => { + if (isSubmitting) return; // console.log(values) + setIsSubmitting(true); HttpUtils.post({ url: UrlUtils.POST_FORGOT_PASSWORD_EMAIL, params: { @@ -67,11 +70,13 @@ const ForgotPasswordApplyForm = () => { }, // files: [attachment], onSuccess: function () { + setIsSubmitting(false); // notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') navigate('/forgot/password/sent'); // location.reload(); }, - onError:function () { + onError: function () { + setIsSubmitting(false); navigate('/forgot/password/sent'); } }); @@ -177,8 +182,9 @@ const ForgotPasswordApplyForm = () => { aria-label={intl.formatMessage({id: 'continue'})} variant="contained" type="submit" + disabled={isSubmitting} > - + {isSubmitting ? : } diff --git a/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js b/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js index 4261a26..9d8981d 100644 --- a/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js +++ b/src/pages/authentication/ForgotUsername/ForgotUsernameApplyForm.js @@ -33,6 +33,7 @@ import {FormattedMessage, useIntl} from "react-intl"; const ForgotUsernameApplyForm = () => { const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); + const [isSubmitting, setIsSubmitting] = React.useState(false); // const [warningText, setWarningText] = React.useState("");s // const [attachment, setAttachment] = React.useState({}); const intl = useIntl(); @@ -61,7 +62,9 @@ const ForgotUsernameApplyForm = () => { emailAddress: yup.string().email(intl.formatMessage({id: 'validEmailFormat'})).max(255).required(intl.formatMessage({id: 'requireEmail'})), }), onSubmit: values => { + if (isSubmitting) return; // console.log(values) + setIsSubmitting(true); HttpUtils.post({ url: UrlUtils.POST_FORGOT_USERNAME_EMAIL, params: { @@ -69,11 +72,13 @@ const ForgotUsernameApplyForm = () => { }, // files: [attachment], onSuccess: function () { + setIsSubmitting(false); // notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') navigate('/forgot/username/sent'); // location.reload(); }, - onError:function () { + onError: function () { + setIsSubmitting(false); navigate('/forgot/username/sent'); } }); @@ -176,8 +181,9 @@ const ForgotUsernameApplyForm = () => { aria-label={intl.formatMessage({id: 'continue'})} variant="contained" type="submit" + disabled={isSubmitting} > - + {isSubmitting ? : } diff --git a/src/translations/en.json b/src/translations/en.json index 29d714c..567a811 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -92,6 +92,7 @@ "MSG.payMsg3": "If you have multiple Public Notice applications within the Year {issueYear}, Volume {issueVolume}, Issue {issueNo} of the Gazette, you can choose to combine the payments for all the approved manuscripts within this issue in 'My Public Notice' before the payment deadline.", "MSG.proofOutOfTime": "Proofing timed out. Please apply again.", + "MSG.proofAlreadyReplied": "This proof has already been replied to. Please refresh the page.", "MSG.overReviseDeadline": "Deadline for online manuscript revision is over. Please apply again as necessary.", "MSG.plzSelectPaymentMethod": "Please select payment methods", "MSG.plzSelectApp": "Please select application", diff --git a/src/translations/zh-CN.json b/src/translations/zh-CN.json index 375c57d..3e385d6 100644 --- a/src/translations/zh-CN.json +++ b/src/translations/zh-CN.json @@ -128,6 +128,7 @@ "MSG.payMsg3": "如你在宪报期数{issueYear} 年{issueVolume} 卷, 第{issueNo} 期内有多于一个公共启事的申请,你可选择完成此期所有稿件校对确定后,于缴费限期前在「我的公共启事」内合并付款。", "MSG.proofOutOfTime": "回复逾时,请重新申请。", + "MSG.proofAlreadyReplied": "此校对已回复,请刷新页面。", "MSG.overReviseDeadline": "网上俢订稿件最后限期已过,请按情况重新申请。", "MSG.plzSelectPaymentMethod": "请选择付款方式", "MSG.plzSelectApp": "请选择公共启事。", diff --git a/src/translations/zh-HK.json b/src/translations/zh-HK.json index 59d84bd..410f96a 100644 --- a/src/translations/zh-HK.json +++ b/src/translations/zh-HK.json @@ -128,6 +128,7 @@ "MSG.payMsg3": "如你在憲報期數 {issueYear} 年 {issueVolume} 卷, 第 {issueNo} 期內有多於一個公共啟事的申請,你可選擇完成此期所有稿件校對確定後,於繳費限期前在「我的公共啟事」內合併付款。", "MSG.proofOutOfTime": "回覆逾時,請重新申請。", + "MSG.proofAlreadyReplied": "此校對已回覆,請重新整理頁面。", "MSG.overReviseDeadline": "網上俢訂稿件最後限期已過,請按情況重新申請。", "MSG.plzSelectApp": "請選擇公共啟事。", "MSG.plzSelectPaymentMethod": "請選擇付款方式",