Alex Cheung 1 year ago
parent
commit
30bdf28ede
4 changed files with 97 additions and 74 deletions
  1. +94
    -74
      src/pages/Proof/Reply_Public/ProofForm.js
  2. +1
    -0
      src/translations/en.json
  3. +1
    -0
      src/translations/zh-CN.json
  4. +1
    -0
      src/translations/zh-HK.json

+ 94
- 74
src/pages/Proof/Reply_Public/ProofForm.js View File

@@ -22,9 +22,9 @@ import { useNavigate } from "react-router-dom";
import * as DateUtils from "utils/DateUtils" import * as DateUtils from "utils/DateUtils"
import Loadable from 'components/Loadable'; import Loadable from 'components/Loadable';
import { notifyActionSuccess } from 'utils/CommonFunction'; 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'))); const UploadFileTable = Loadable(React.lazy(() => import('./UploadFileTable')));
//import * as ProofStatus from "utils/statusUtils/ProofStatus"; //import * as ProofStatus from "utils/statusUtils/ProofStatus";


@@ -55,22 +55,28 @@ const FormPanel = ({ formData }) => {
enableReinitialize: true, enableReinitialize: true,
initialValues: data, initialValues: data,
validationSchema: yup.object().shape({ 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 => { 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 (!actionValue) {
if (!attachments || attachments.length <= 0) { if (!attachments || attachments.length <= 0) {
setWarningText(intl.formatMessage({id: 'requireFile'}));
setWarningText(intl.formatMessage({ id: 'requireFile' }));
setIsWarningPopUp(true); setIsWarningPopUp(true);
return; return;
} }
} }

if (isOverTime()) {
setWarningText(intl.formatMessage({id: 'MSG.proofOutOfTime'}));
setIsWarningPopUp(true);
return;
}
// console.log(values); // console.log(values);
HttpUtils.postWithFiles({ HttpUtils.postWithFiles({
url: UrlUtils.REPLY_PROOF, url: UrlUtils.REPLY_PROOF,
@@ -81,8 +87,8 @@ const FormPanel = ({ formData }) => {
}, },
files: attachments ? attachments : [], files: attachments ? attachments : [],
onSuccess: function (responseData) { onSuccess: function (responseData) {
if(responseData.msg){
setWarningText(intl.formatMessage({id: 'MSG.proofOutOfTime'}));
if (responseData.msg) {
setWarningText(intl.formatMessage({ id: 'MSG.proofOutOfTime' }));
setIsWarningPopUp(true); setIsWarningPopUp(true);
return; return;
} }
@@ -94,12 +100,12 @@ const FormPanel = ({ formData }) => {
} }
}, },
onFail: function (response) { onFail: function (response) {
setWarningText(intl.formatMessage({id: 'actionFail'}));
setWarningText(intl.formatMessage({ id: 'actionFail' }));
setIsWarningPopUp(true); setIsWarningPopUp(true);
console.log(response); console.log(response);
}, },
onError: function (error) { onError: function (error) {
setWarningText(intl.formatMessage({id: 'actionFail'}));
setWarningText(intl.formatMessage({ id: 'actionFail' }));
setIsWarningPopUp(true); setIsWarningPopUp(true);
console.log(error); console.log(error);
} }
@@ -111,13 +117,13 @@ const FormPanel = ({ formData }) => {
let file = event.target.files[0]; let file = event.target.files[0];
if (file) { if (file) {
if (!file.name.toLowerCase().substr(file.name.length - 4).includes(".pdf")) { if (!file.name.toLowerCase().substr(file.name.length - 4).includes(".pdf")) {
setWarningText(intl.formatMessage({id: 'requireValidFileWithPdfFormat'}));
setWarningText(intl.formatMessage({ id: 'requireValidFileWithPdfFormat' }));
setIsWarningPopUp(true); setIsWarningPopUp(true);
document.getElementById("uploadFileBtn").value = ""; document.getElementById("uploadFileBtn").value = "";
return; return;
} }
if (file.size >= (10 * 1024 * 1034)) { if (file.size >= (10 * 1024 * 1034)) {
setWarningText(intl.formatMessage({id: 'fileSizeWarning'}));
setWarningText(intl.formatMessage({ id: 'fileSizeWarning' }));
setIsWarningPopUp(true); setIsWarningPopUp(true);
return; return;
} }
@@ -132,6 +138,13 @@ const FormPanel = ({ formData }) => {
} }


const isOverTime = () => { 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); let reviseDeadline = DateUtils.convertToDate(formik.values?.reviseDeadline);
if (!reviseDeadline) return true; if (!reviseDeadline) return true;
let current = new Date(); let current = new Date();
@@ -146,7 +159,7 @@ const FormPanel = ({ formData }) => {
content={false}> content={false}>


<Typography variant="h4" sx={{ textAlign: "left", mb: 2, borderBottom: "1px solid black" }}> <Typography variant="h4" sx={{ textAlign: "left", mb: 2, borderBottom: "1px solid black" }}>
<FormattedMessage id="publicNoticePaymentProofComment"/>
<FormattedMessage id="publicNoticePaymentProofComment" />
</Typography> </Typography>


<form onSubmit={formik.handleSubmit}> <form onSubmit={formik.handleSubmit}>
@@ -168,13 +181,13 @@ const FormPanel = ({ formData }) => {
<Grid item xs={12} md={12} textAlign="left"> <Grid item xs={12} md={12} textAlign="left">
<Typography variant="h5"> <Typography variant="h5">
<FormattedMessage id="proofReply" /> : {formik.values.action ? <FormattedMessage id="proofReply" /> : {formik.values.action ?
(<span style={{ color: 'green' }}>
<FormattedMessage id="proofErrorFree" />
</span>)
:
(<span style={{ color: 'red' }}>
<FormattedMessage id="proofWithError" />
</span>)}
(<span style={{ color: 'green' }}>
<FormattedMessage id="proofErrorFree" />
</span>)
:
(<span style={{ color: 'red' }}>
<FormattedMessage id="proofWithError" />
</span>)}
</Typography> </Typography>
</Grid> </Grid>
{/* <Grid item xs={12} md={12} textAlign="left"> {/* <Grid item xs={12} md={12} textAlign="left">
@@ -194,7 +207,7 @@ const FormPanel = ({ formData }) => {
formik.values.action ? formik.values.action ?
null null
: :
<Grid item xs={12} md={12} textAlign="left" sx={{ width:'95%', maxWidth: {xs:'70vw', sm:'72vw', md:'75vw',lg:'80vw'}}}>
<Grid item xs={12} md={12} textAlign="left" sx={{ width: '95%', maxWidth: { xs: '70vw', sm: '72vw', md: '75vw', lg: '80vw' } }}>
<FileList <FileList
lang="ch" lang="ch"
refId={params.id} refId={params.id}
@@ -231,8 +244,8 @@ const FormPanel = ({ formData }) => {
setActionValue(event.target.value === "true" ? true : false); setActionValue(event.target.value === "true" ? true : false);
}} }}
> >
<FormControlLabel value={true} control={<Radio />} label={intl.formatMessage({id: 'proofErrorFree'})} />
<FormControlLabel value={false} control={<Radio />} label={intl.formatMessage({id: 'proofWithError'})} />
<FormControlLabel value={true} control={<Radio />} label={intl.formatMessage({ id: 'proofErrorFree' })} />
<FormControlLabel value={false} control={<Radio />} label={intl.formatMessage({ id: 'proofWithError' })} />
</RadioGroup> </RadioGroup>
</Grid> </Grid>


@@ -241,45 +254,52 @@ const FormPanel = ({ formData }) => {
actionValue ? actionValue ?
null null
: :
<>
isOverReviseDeadline() ?
<Grid item xs={12} md={12} textAlign="left"> <Grid item xs={12} md={12} textAlign="left">
<Typography variant="h5">
<FormattedMessage id="requiredUploadFix" />:
<Typography variant="h5" style={{color:"red"}}>
<FormattedMessage id="MSG.overReviseDeadline" />
</Typography> </Typography>
</Grid> </Grid>

<Grid item xs={12} md={12} textAlign="left">
<input
id="uploadFileBtn"
name="file"
type="file"
accept=".pdf"
style={{ display: 'none' }}
disabled={attachments.length >= (formik.values.groupType === "Private Bill" ? 2 : 1)}
onChange={(event) => {
readFile(event)
}}
/>
<label htmlFor="uploadFileBtn">
<ThemeProvider theme={PNSPS_BUTTON_THEME}>
<Button
color="save"
component="span"
variant="contained"
aria-label={intl.formatMessage({id: 'upload'})}
:
<>
<Grid item xs={12} md={12} textAlign="left">
<Typography variant="h5">
<FormattedMessage id="requiredUploadFix" />:
</Typography>
</Grid>

<Grid item xs={12} md={12} textAlign="left">
<input
id="uploadFileBtn"
name="file"
type="file"
accept=".pdf"
style={{ display: 'none' }}
disabled={attachments.length >= (formik.values.groupType === "Private Bill" ? 2 : 1)} disabled={attachments.length >= (formik.values.groupType === "Private Bill" ? 2 : 1)}
>
<FormattedMessage id="upload" />
</Button>
</ThemeProvider>
</label>
</Grid>


<Grid item xs={12} sm={12} md={12} lg={12} textAlign="left" sx={{ width:'95%', maxWidth: {xs:'70vw', sm:'72vw', md:'75vw',lg:'80vw'}}} >
<UploadFileTable key="uploadTable" recordList={attachments} setRecordList={setAttachments} />
</Grid>
</>
onChange={(event) => {
readFile(event)
}}
/>
<label htmlFor="uploadFileBtn">
<ThemeProvider theme={PNSPS_BUTTON_THEME}>
<Button
color="save"
component="span"
variant="contained"
aria-label={intl.formatMessage({ id: 'upload' })}
disabled={attachments.length >= (formik.values.groupType === "Private Bill" ? 2 : 1)}
>
<FormattedMessage id="upload" />
</Button>
</ThemeProvider>
</label>
</Grid>


<Grid item xs={12} sm={12} md={12} lg={12} textAlign="left" sx={{ width: '95%', maxWidth: { xs: '70vw', sm: '72vw', md: '75vw', lg: '80vw' } }} >
<UploadFileTable key="uploadTable" recordList={attachments} setRecordList={setAttachments} />
</Grid>
</>
} }


<Grid item xs={12} sm={12} md={12} lg={12}> <Grid item xs={12} sm={12} md={12} lg={12}>
@@ -297,7 +317,7 @@ const FormPanel = ({ formData }) => {
variant="outlined" variant="outlined"
error={Boolean(formik.errors["vaild"])} error={Boolean(formik.errors["vaild"])}
helperText={formik.errors["vaild"] ? formik.errors["vaild"] : ' '} helperText={formik.errors["vaild"] ? formik.errors["vaild"] : ' '}
placeholder={intl.formatMessage({id: 'requireLoginPassword'})}
placeholder={intl.formatMessage({ id: 'requireLoginPassword' })}
sx={ sx={
{ {
"& .MuiInputBase-input.Mui-disabled": { "& .MuiInputBase-input.Mui-disabled": {
@@ -315,14 +335,14 @@ const FormPanel = ({ formData }) => {


<Grid item xs={12} md={12} textAlign="left"> <Grid item xs={12} md={12} textAlign="left">
<ThemeProvider theme={PNSPS_BUTTON_THEME}> <ThemeProvider theme={PNSPS_BUTTON_THEME}>
<Button
variant="contained"
color="success"
type="submit"
aria-label={intl.formatMessage({id: 'submitReply'})}
>
<FormattedMessage id="submitReply" />
</Button>
<Button
variant="contained"
color="success"
type="submit"
aria-label={intl.formatMessage({ id: 'submitReply' })}
>
<FormattedMessage id="submitReply" />
</Button>
</ThemeProvider> </ThemeProvider>
</Grid> </Grid>


@@ -349,14 +369,14 @@ const FormPanel = ({ formData }) => {
}} }}
> >
<DialogTitle> <DialogTitle>
<FormattedMessage id="attention"/>
<FormattedMessage id="attention" />
</DialogTitle> </DialogTitle>
<DialogContent style={{ display: 'flex', }}> <DialogContent style={{ display: 'flex', }}>
<Typography variant="h3" style={{ padding: '16px' }}>{warningText}</Typography> <Typography variant="h3" style={{ padding: '16px' }}>{warningText}</Typography>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button <Button
aria-label={intl.formatMessage({id: 'ok'})}
aria-label={intl.formatMessage({ id: 'ok' })}
onClick={() => setIsWarningPopUp(false)} onClick={() => setIsWarningPopUp(false)}
> >
OK OK


+ 1
- 0
src/translations/en.json View File

@@ -68,6 +68,7 @@
"MSG.payMsg3": "If you have multiple Public Notice applications within the Year {issueYear}, Volume {issueVolume}, Issue {issueNo} of the Official Gazette, you can choose to merge the payment for all the approved manuscripts within this issue in 'My Public Notice' before the payment deadline.", "MSG.payMsg3": "If you have multiple Public Notice applications within the Year {issueYear}, Volume {issueVolume}, Issue {issueNo} of the Official Gazette, you can choose to merge the payment for all the approved manuscripts within this issue in 'My Public Notice' before the payment deadline.",


"MSG.proofOutOfTime": "Response out of time, please apply again.", "MSG.proofOutOfTime": "Response out of time, please apply again.",
"MSG.overReviseDeadline": "Over Revise Deadline",
"MSG.plzSelectApp": "Please select application", "MSG.plzSelectApp": "Please select application",
"MSG.actionFail": "Action failed", "MSG.actionFail": "Action failed",
"MSG.paymentHolded": "Application number {appNo} is currently in the process of payment. If the payment is unsuccessful, please try again after 20 minutes. We apologise for any inconvenience caused.", "MSG.paymentHolded": "Application number {appNo} is currently in the process of payment. If the payment is unsuccessful, please try again after 20 minutes. We apologise for any inconvenience caused.",


+ 1
- 0
src/translations/zh-CN.json View File

@@ -67,6 +67,7 @@
"MSG.payMsg3": "如你在宪报期数{issueYear} 年{issueVolume} 卷, 第{issueNo} 期内有多于一个公共启事的申请,你可选择完成所有此期所有稿件校对确定后,于缴费期限前在「我的公共启事」内合并付款。 ", "MSG.payMsg3": "如你在宪报期数{issueYear} 年{issueVolume} 卷, 第{issueNo} 期内有多于一个公共启事的申请,你可选择完成所有此期所有稿件校对确定后,于缴费期限前在「我的公共启事」内合并付款。 ",


"MSG.proofOutOfTime": "回复逾时,请重新申请。", "MSG.proofOutOfTime": "回复逾时,请重新申请。",
"MSG.overReviseDeadline": "超过修改期限",
"MSG.plzSelectApp": "请选择公共启事。", "MSG.plzSelectApp": "请选择公共启事。",
"MSG.actionFail": "行动失败", "MSG.actionFail": "行动失败",
"MSG.paymentHolded": "申请编号 {appNo} 已正在付款的流程中,如相关付款没有成功,请于20分钟后再尝试付款,不便之处,请见谅!", "MSG.paymentHolded": "申请编号 {appNo} 已正在付款的流程中,如相关付款没有成功,请于20分钟后再尝试付款,不便之处,请见谅!",


+ 1
- 0
src/translations/zh-HK.json View File

@@ -67,6 +67,7 @@
"MSG.payMsg3": "如你在憲報期數 {issueYear} 年 {issueVolume} 卷, 第 {issueNo} 期內有多於一個公共啟事的申請,你可選擇完成所有此期所有稿件校對確定後,於繳費期限前在「我的公共啟事」內合併付款。", "MSG.payMsg3": "如你在憲報期數 {issueYear} 年 {issueVolume} 卷, 第 {issueNo} 期內有多於一個公共啟事的申請,你可選擇完成所有此期所有稿件校對確定後,於繳費期限前在「我的公共啟事」內合併付款。",


"MSG.proofOutOfTime": "回覆逾時,請重新申請。", "MSG.proofOutOfTime": "回覆逾時,請重新申請。",
"MSG.overReviseDeadline": "超過修改期限",
"MSG.plzSelectApp": "請選擇公共啟事。", "MSG.plzSelectApp": "請選擇公共啟事。",
"MSG.actionFail": "行動失敗", "MSG.actionFail": "行動失敗",
"MSG.paymentHolded": "申請編號 {appNo} 已正在付款的流程中,如相關付款沒有成功,請於20分鐘後再嘗試付款,不便之處,請見諒!", "MSG.paymentHolded": "申請編號 {appNo} 已正在付款的流程中,如相關付款沒有成功,請於20分鐘後再嘗試付款,不便之處,請見諒!",


Loading…
Cancel
Save