From 3c9d846ec167498192c6c44e1d326448f66fa5a1 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 22 Mar 2024 17:21:53 +0800 Subject: [PATCH] update public proof --- src/pages/Proof/Reply_Public/ProofForm.js | 168 ++++++++++++---------- src/translations/en.json | 1 + src/translations/zh-CN.json | 1 + src/translations/zh-HK.json | 1 + 4 files changed, 97 insertions(+), 74 deletions(-) diff --git a/src/pages/Proof/Reply_Public/ProofForm.js b/src/pages/Proof/Reply_Public/ProofForm.js index eebd6b7..d160ccf 100644 --- a/src/pages/Proof/Reply_Public/ProofForm.js +++ b/src/pages/Proof/Reply_Public/ProofForm.js @@ -22,9 +22,9 @@ import { useNavigate } from "react-router-dom"; import * as DateUtils from "utils/DateUtils" import Loadable from 'components/Loadable'; import { notifyActionSuccess } from 'utils/CommonFunction'; -import {PNSPS_BUTTON_THEME} from "themes/buttonConst"; -import {ThemeProvider} from "@emotion/react"; -import {FormattedMessage, useIntl} from "react-intl"; +import { PNSPS_BUTTON_THEME } from "themes/buttonConst"; +import { ThemeProvider } from "@emotion/react"; +import { FormattedMessage, useIntl } from "react-intl"; const UploadFileTable = Loadable(React.lazy(() => import('./UploadFileTable'))); //import * as ProofStatus from "utils/statusUtils/ProofStatus"; @@ -55,22 +55,28 @@ const FormPanel = ({ formData }) => { enableReinitialize: true, initialValues: data, validationSchema: yup.object().shape({ - vaild: yup.string().max(255, intl.formatMessage({id: 'requireLoginPassword'})).required(intl.formatMessage({id: 'requireLoginPassword'})), + vaild: yup.string().max(255, intl.formatMessage({ id: 'requireLoginPassword' })).required(intl.formatMessage({ id: 'requireLoginPassword' })), }), onSubmit: values => { + if (isOverTime()) { + setWarningText(intl.formatMessage({ id: 'MSG.proofOutOfTime' })); + setIsWarningPopUp(true); + return; + } + + if (actionValue == false && isOverReviseDeadline()) { + setWarningText(intl.formatMessage({ id: 'MSG.overReviseDeadline' })); + setIsWarningPopUp(true); + return; + } + if (!actionValue) { if (!attachments || attachments.length <= 0) { - setWarningText(intl.formatMessage({id: 'requireFile'})); + setWarningText(intl.formatMessage({ id: 'requireFile' })); setIsWarningPopUp(true); return; } } - - if (isOverTime()) { - setWarningText(intl.formatMessage({id: 'MSG.proofOutOfTime'})); - setIsWarningPopUp(true); - return; - } // console.log(values); HttpUtils.postWithFiles({ url: UrlUtils.REPLY_PROOF, @@ -81,8 +87,8 @@ const FormPanel = ({ formData }) => { }, files: attachments ? attachments : [], onSuccess: function (responseData) { - if(responseData.msg){ - setWarningText(intl.formatMessage({id: 'MSG.proofOutOfTime'})); + if (responseData.msg) { + setWarningText(intl.formatMessage({ id: 'MSG.proofOutOfTime' })); setIsWarningPopUp(true); return; } @@ -94,12 +100,12 @@ const FormPanel = ({ formData }) => { } }, onFail: function (response) { - setWarningText(intl.formatMessage({id: 'actionFail'})); + setWarningText(intl.formatMessage({ id: 'actionFail' })); setIsWarningPopUp(true); console.log(response); }, onError: function (error) { - setWarningText(intl.formatMessage({id: 'actionFail'})); + setWarningText(intl.formatMessage({ id: 'actionFail' })); setIsWarningPopUp(true); console.log(error); } @@ -111,13 +117,13 @@ const FormPanel = ({ formData }) => { let file = event.target.files[0]; if (file) { if (!file.name.toLowerCase().substr(file.name.length - 4).includes(".pdf")) { - setWarningText(intl.formatMessage({id: 'requireValidFileWithPdfFormat'})); + setWarningText(intl.formatMessage({ id: 'requireValidFileWithPdfFormat' })); setIsWarningPopUp(true); document.getElementById("uploadFileBtn").value = ""; return; } if (file.size >= (10 * 1024 * 1034)) { - setWarningText(intl.formatMessage({id: 'fileSizeWarning'})); + setWarningText(intl.formatMessage({ id: 'fileSizeWarning' })); setIsWarningPopUp(true); return; } @@ -132,6 +138,13 @@ const FormPanel = ({ formData }) => { } const isOverTime = () => { + let proofPaymentDeadline = DateUtils.convertToDate(formik.values?.proofPaymentDeadline); + if (!proofPaymentDeadline) return true; + let current = new Date(); + return current.getTime() > proofPaymentDeadline; + } + + const isOverReviseDeadline = () => { let reviseDeadline = DateUtils.convertToDate(formik.values?.reviseDeadline); if (!reviseDeadline) return true; let current = new Date(); @@ -146,7 +159,7 @@ const FormPanel = ({ formData }) => { content={false}> - +
@@ -168,13 +181,13 @@ const FormPanel = ({ formData }) => { : {formik.values.action ? - ( - - ) - : - ( - - )} + ( + + ) + : + ( + + )} {/* @@ -194,7 +207,7 @@ const FormPanel = ({ formData }) => { formik.values.action ? null : - + { setActionValue(event.target.value === "true" ? true : false); }} > - } label={intl.formatMessage({id: 'proofErrorFree'})} /> - } label={intl.formatMessage({id: 'proofWithError'})} /> + } label={intl.formatMessage({ id: 'proofErrorFree' })} /> + } label={intl.formatMessage({ id: 'proofWithError' })} /> @@ -241,45 +254,52 @@ const FormPanel = ({ formData }) => { actionValue ? null : - <> + isOverReviseDeadline() ? - - : + + - - - = (formik.values.groupType === "Private Bill" ? 2 : 1)} - onChange={(event) => { - readFile(event) - }} - /> - - - - - - - - + onChange={(event) => { + readFile(event) + }} + /> + + + + + + + + } @@ -297,7 +317,7 @@ const FormPanel = ({ formData }) => { variant="outlined" error={Boolean(formik.errors["vaild"])} helperText={formik.errors["vaild"] ? formik.errors["vaild"] : ' '} - placeholder={intl.formatMessage({id: 'requireLoginPassword'})} + placeholder={intl.formatMessage({ id: 'requireLoginPassword' })} sx={ { "& .MuiInputBase-input.Mui-disabled": { @@ -315,14 +335,14 @@ const FormPanel = ({ formData }) => { - + @@ -349,14 +369,14 @@ const FormPanel = ({ formData }) => { }} > - + {warningText}