diff --git a/src/pages/Proof/Reply_Public/ProofForm.js b/src/pages/Proof/Reply_Public/ProofForm.js index cfa395a..764b4a2 100644 --- a/src/pages/Proof/Reply_Public/ProofForm.js +++ b/src/pages/Proof/Reply_Public/ProofForm.js @@ -7,6 +7,7 @@ import { TextField, FormLabel, Button, + CircularProgress, Checkbox, RadioGroup, Radio, FormControlLabel @@ -51,6 +52,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 +89,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 +127,7 @@ const FormPanel = ({ formData }) => { } } // console.log(values); + setIsSubmitting(true); HttpUtils.postWithFiles({ url: UrlUtils.REPLY_PROOF, params: { @@ -134,8 +138,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 +164,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); @@ -689,7 +702,8 @@ const FormPanel = ({ formData }) => { variant="contained" color="success" type="submit" - disabled={actionValue == false && isOverReviseDeadline()} + disabled={(actionValue == false && isOverReviseDeadline()) || isSubmitting} + startIcon={isSubmitting ? : null} aria-label={intl.formatMessage({ id: 'submitReply' })} > diff --git a/src/translations/en.json b/src/translations/en.json index 0f41b37..e106d0a 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -84,6 +84,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 260d437..019667f 100644 --- a/src/translations/zh-CN.json +++ b/src/translations/zh-CN.json @@ -120,6 +120,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 48fdc35..059baa3 100644 --- a/src/translations/zh-HK.json +++ b/src/translations/zh-HK.json @@ -120,6 +120,7 @@ "MSG.payMsg3": "如你在憲報期數 {issueYear} 年 {issueVolume} 卷, 第 {issueNo} 期內有多於一個公共啟事的申請,你可選擇完成此期所有稿件校對確定後,於繳費限期前在「我的公共啟事」內合併付款。", "MSG.proofOutOfTime": "回覆逾時,請重新申請。", + "MSG.proofAlreadyReplied": "此校對已回覆,請重新整理頁面。", "MSG.overReviseDeadline": "網上俢訂稿件最後限期已過,請按情況重新申請。", "MSG.plzSelectApp": "請選擇公共啟事。", "MSG.plzSelectPaymentMethod": "請選擇付款方式",