From 45e4b03d098eed574fe46798766c6d3bff74537c Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 7 Feb 2024 17:43:42 +0800 Subject: [PATCH] apply application pop up warning when dn overdue --- .../ApplyForm/PublicNoticeApplyForm.js | 79 +++++++++++++------ src/translations/en.json | 1 + src/translations/zh-CN.json | 1 + src/translations/zh-HK.json | 1 + src/utils/ApiPathConst.js | 2 + 5 files changed, 59 insertions(+), 25 deletions(-) diff --git a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js index 09b1d72..5d5cd95 100644 --- a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js +++ b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js @@ -33,6 +33,8 @@ const PublicNoticeApplyForm = ({ loadedData, selections }) => { const [attachment, setAttachment] = React.useState({}); const intl = useIntl(); + const [val, setVal] = React.useState({}); + const [issueId, setIssueId] = React.useState(loadedData.issueId); const navigate = useNavigate(); @@ -80,33 +82,53 @@ const PublicNoticeApplyForm = ({ loadedData, selections }) => { setIsWarningPopUp(true); return; } - HttpUtils.postWithFiles({ - url: UrlUtils.POST_PUBLIC_NOTICE_APPLY, - params: { - id: 0, - contactPerson: values.contactPerson, - contactTelNo: { - countryCode: values.tel_countryCode, - phoneNumber: values.phoneNumber - }, - contactFaxNo: { - countryCode: values.fax_countryCode, - faxNumber: values.faxNumber - }, - issueId: issueId, - careOf: values.careOf ? values.careOf: "", - remarks: values.remarks ? values.remarks : "", - }, - files: [attachment], - onSuccess: function () { - notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') - navigate("/publicNotice"); - // location.reload(); - } - }); + if(isORGLoggedIn()){ + HttpUtils.get({ + url: UrlUtils.CHECK_OVERDUE, + onSuccess: (responData)=>{ + if(responData.haveOverdue){ + setVal(values); + setWarningText(intl.formatMessage({id: 'dnOverdueWarning'})); + setIsWarningPopUp(true); + }else{ + apply(values); + } + } + }); + }else{ + apply(values); + } + } }); + const apply = (values)=>{ + HttpUtils.postWithFiles({ + url: UrlUtils.POST_PUBLIC_NOTICE_APPLY, + params: { + id: 0, + contactPerson: values.contactPerson, + contactTelNo: { + countryCode: values.tel_countryCode, + phoneNumber: values.phoneNumber + }, + contactFaxNo: { + countryCode: values.fax_countryCode, + faxNumber: values.faxNumber + }, + issueId: issueId, + careOf: values.careOf ? values.careOf: "", + remarks: values.remarks ? values.remarks : "", + }, + files: [attachment], + onSuccess: function () { + notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') + navigate("/publicNotice"); + // location.reload(); + } + }); + } + const readFile = (event) => { let file = event.target.files[0]; if (file) { @@ -317,7 +339,14 @@ const PublicNoticeApplyForm = ({ loadedData, selections }) => { diff --git a/src/translations/en.json b/src/translations/en.json index 1c52bcc..2709d54 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -157,6 +157,7 @@ "fileName": "File name", "fileSize": "File size", "fileSizeWarning": "Upload file size should be <10MB", + "dnOverdueWarning": "Please settle the outstanding demand note(s) as soon as possible.", "noFile": "No file uploaded", "termsAndCondition": "Terms and Conditions", "acceptTerms": "I accept", diff --git a/src/translations/zh-CN.json b/src/translations/zh-CN.json index 47c4489..4a92306 100644 --- a/src/translations/zh-CN.json +++ b/src/translations/zh-CN.json @@ -155,6 +155,7 @@ "fileName": "档案名称", "fileSize": "档案大小", "fileSizeWarning": "上传档案大小应<10MB", + "dnOverdueWarning": "请尽快缴付所有逾期未缴交的款额。", "noFile": "没有上传档案", "termsAndCondition": "条款和条件", "acceptTerms": "我接受", diff --git a/src/translations/zh-HK.json b/src/translations/zh-HK.json index c5b81fe..6828519 100644 --- a/src/translations/zh-HK.json +++ b/src/translations/zh-HK.json @@ -158,6 +158,7 @@ "fileName": "檔案名稱", "fileSize": "檔案大小", "fileSizeWarning": "上傳檔案大小應<10MB", + "dnOverdueWarning": "請盡快繳付所有逾期未繳交的款額。", "noFile": "沒有上傳檔案", "termsAndCondition": "條款和條件", "acceptTerms": "我接受", diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index a6b69fe..17e98f6 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -51,6 +51,8 @@ export const GET_MSG_DETAILS = apiPath+'/msg/details'; export const GET_MSG_LIST = apiPath+'/msg/list'; export const GET_MSG_DESHBOARD = apiPath+'/msg/list/deshboard'; +export const CHECK_OVERDUE = apiPath+'/application/check-overdue'; + //File Up/Download