| @@ -185,12 +185,25 @@ const FormPanel = ({ formData }) => { | |||||
| } | } | ||||
| }); | }); | ||||
| const getFileExtension = (fileName) => { | |||||
| const name = (fileName || "").toLowerCase(); | |||||
| const dot = name.lastIndexOf("."); | |||||
| if (dot <= 0 || dot === name.length - 1) { | |||||
| return ""; | |||||
| } | |||||
| return name.substring(dot + 1); | |||||
| } | |||||
| const isAcceptedProofReplyFile = (fileName) => { | |||||
| return ["pdf", "jpg", "jpeg", "png"].includes(getFileExtension(fileName)); | |||||
| } | |||||
| const readFile = (event) => { | const readFile = (event) => { | ||||
| 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 (!isAcceptedProofReplyFile(file.name)) { | |||||
| setWarningTitle(intl.formatMessage({ id: "attention" })) | setWarningTitle(intl.formatMessage({ id: "attention" })) | ||||
| setWarningText(intl.formatMessage({ id: 'requireValidFileWithPdfFormat' })); | |||||
| setWarningText(intl.formatMessage({ id: 'requireValidFileWithProofReplyFormat' })); | |||||
| setIsWarningPopUp(true); | setIsWarningPopUp(true); | ||||
| document.getElementById("uploadFileBtn").value = ""; | document.getElementById("uploadFileBtn").value = ""; | ||||
| return; | return; | ||||
| @@ -630,6 +643,11 @@ const FormPanel = ({ formData }) => { | |||||
| <FormattedMessage id="requiredUploadFix" />: | <FormattedMessage id="requiredUploadFix" />: | ||||
| </Typography> | </Typography> | ||||
| </Grid> | </Grid> | ||||
| <Grid item xs={12} md={12} textAlign="left"> | |||||
| <Typography variant="subtitle1" component="span" sx={{ color: 'primary.primary' }}> | |||||
| <FormattedMessage id="acceptProofReplyFileFormats" /> | |||||
| </Typography> | |||||
| </Grid> | |||||
| <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}> | ||||
| @@ -660,7 +678,7 @@ const FormPanel = ({ formData }) => { | |||||
| id="uploadFileBtn" | id="uploadFileBtn" | ||||
| name="file" | name="file" | ||||
| type="file" | type="file" | ||||
| accept=".pdf" | |||||
| accept=".pdf,.jpg,.jpeg,.png,application/pdf,image/jpeg,image/png" | |||||
| style={{ display: 'none' }} | style={{ display: 'none' }} | ||||
| disabled={attachments.length >= (formik.values.groupType === "Private Bill" ? 2 : 1)} | disabled={attachments.length >= (formik.values.groupType === "Private Bill" ? 2 : 1)} | ||||
| onChange={(event) => { | onChange={(event) => { | ||||
| @@ -44,6 +44,8 @@ | |||||
| "requireFile": "Please select a file to upload", | "requireFile": "Please select a file to upload", | ||||
| "requireValidFile": "Please upload a valid file", | "requireValidFile": "Please upload a valid file", | ||||
| "requireValidFileWithPdfFormat": "Please upload a valid file (file format: .pdf)", | "requireValidFileWithPdfFormat": "Please upload a valid file (file format: .pdf)", | ||||
| "requireValidFileWithProofReplyFormat": "Please upload a valid file (file format: .pdf, .jpg, .jpeg, .png)", | |||||
| "acceptProofReplyFileFormats": "Accept file formats: pdf, jpg, jpeg and png.", | |||||
| "requireValidFileWithFormat": "Please upload a valid file (file format: .doc, .docx, .xls, .xlsx)", | "requireValidFileWithFormat": "Please upload a valid file (file format: .doc, .docx, .xls, .xlsx)", | ||||
| "submissionSuccess": "Application submitted successfully", | "submissionSuccess": "Application submitted successfully", | ||||
| "noMoreThen40Words": "Must not exceed 40 characters", | "noMoreThen40Words": "Must not exceed 40 characters", | ||||
| @@ -44,6 +44,8 @@ | |||||
| "requireFile": "请选择上传档案", | "requireFile": "请选择上传档案", | ||||
| "requireValidFile": "请上传有效档案", | "requireValidFile": "请上传有效档案", | ||||
| "requireValidFileWithPdfFormat": "请上传有效档案 (档案格式: .pdf)", | "requireValidFileWithPdfFormat": "请上传有效档案 (档案格式: .pdf)", | ||||
| "requireValidFileWithProofReplyFormat": "请上传有效档案 (档案格式: .pdf, .jpg, .jpeg, .png)", | |||||
| "acceptProofReplyFileFormats": "接受档案格式:pdf、jpg、jpeg 及 png。", | |||||
| "requireValidFileWithFormat": "请上传有效档案 (档案格式: .doc, .docx, .xls, .xlsx)", | "requireValidFileWithFormat": "请上传有效档案 (档案格式: .doc, .docx, .xls, .xlsx)", | ||||
| "submissionSuccess": "申请提交成功", | "submissionSuccess": "申请提交成功", | ||||
| "noMoreThen40Words": "不得超过 40 个字符", | "noMoreThen40Words": "不得超过 40 个字符", | ||||
| @@ -44,6 +44,8 @@ | |||||
| "requireFile": "請選擇上傳檔案", | "requireFile": "請選擇上傳檔案", | ||||
| "requireValidFile": "請上傳有效檔案", | "requireValidFile": "請上傳有效檔案", | ||||
| "requireValidFileWithPdfFormat": "請上傳有效檔案 (檔案格式: .pdf)", | "requireValidFileWithPdfFormat": "請上傳有效檔案 (檔案格式: .pdf)", | ||||
| "requireValidFileWithProofReplyFormat": "請上傳有效檔案 (檔案格式: .pdf, .jpg, .jpeg, .png)", | |||||
| "acceptProofReplyFileFormats": "接受檔案格式:pdf、jpg、jpeg 及 png。", | |||||
| "requireValidFileWithFormat": "請上傳有效檔案 (檔案格式: .doc, .docx, .xls, .xlsx)", | "requireValidFileWithFormat": "請上傳有效檔案 (檔案格式: .doc, .docx, .xls, .xlsx)", | ||||
| "submissionSuccess": "申請提交成功", | "submissionSuccess": "申請提交成功", | ||||
| "noMoreThen40Words": "不得超過 40 個字符", | "noMoreThen40Words": "不得超過 40 個字符", | ||||