@@ -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}>
<Typography variant="h4" sx={{ textAlign: "left", mb: 2, borderBottom: "1px solid black" }}>
<FormattedMessage id="publicNoticePaymentProofComment"/>
<FormattedMessage id="publicNoticePaymentProofComment" />
</Typography>
<form onSubmit={formik.handleSubmit}>
@@ -168,13 +181,13 @@ const FormPanel = ({ formData }) => {
<Grid item xs={12} md={12} textAlign="left">
<Typography variant="h5">
<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>
</Grid>
{/* <Grid item xs={12} md={12} textAlign="left">
@@ -194,7 +207,7 @@ const FormPanel = ({ formData }) => {
formik.values.action ?
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
lang="ch"
refId={params.id}
@@ -231,8 +244,8 @@ const FormPanel = ({ formData }) => {
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>
</Grid>
@@ -241,45 +254,52 @@ const FormPanel = ({ formData }) => {
actionValue ?
null
:
<>
isOverReviseDeadline() ?
<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>
</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)}
>
<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}>
@@ -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 }) => {
<Grid item xs={12} md={12} textAlign="left">
<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>
</Grid>
@@ -349,14 +369,14 @@ const FormPanel = ({ formData }) => {
}}
>
<DialogTitle>
<FormattedMessage id="attention"/>
<FormattedMessage id="attention" />
</DialogTitle>
<DialogContent style={{ display: 'flex', }}>
<Typography variant="h3" style={{ padding: '16px' }}>{warningText}</Typography>
</DialogContent>
<DialogActions>
<Button
aria-label={intl.formatMessage({id: 'ok'})}
aria-label={intl.formatMessage({ id: 'ok' })}
onClick={() => setIsWarningPopUp(false)}
>
OK