From c82732c46dd58458ed58ae06d229074b9e6833e8 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 3 Feb 2025 11:53:20 +0000 Subject: [PATCH 1/6] ITHC - restrict filetype uploads via api --- pages/api/file/uploadsinglefile.js | 58 +++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/pages/api/file/uploadsinglefile.js b/pages/api/file/uploadsinglefile.js index fd349f1a..382c0888 100644 --- a/pages/api/file/uploadsinglefile.js +++ b/pages/api/file/uploadsinglefile.js @@ -6,40 +6,64 @@ import { import nextConnect from "next-connect"; import middleware from "../middleware/middleware"; +import { consoleLogger } from "../../../actions"; const ApiProxy = nextConnect(); ApiProxy.use(middleware); ApiProxy.post(async (req, res) => { var checkHash = req.query.hash; - console.log(JSON.stringify(req.body)); - console.log(JSON.stringify(req.body.appealData)); - console.log(req.files); + // console.log(JSON.stringify(req.body)); + // console.log(JSON.stringify(req.body.appealData)); + // console.log(req.files); const containerID = req.body.containerID[0]; const casefolderID = req.body.casefolderID[0]; console.log("there are files:", Object.keys(req.files).length); - // var checkquerypath = "/api/file/upload"; + // Add other mimetypes here + const allowedMimeTypes = [ + "application/pdf", + "application/msword", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "image/tiff", + "image/jpeg", + "application/zip", + "image/png", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ]; - //console.log(hashAPIPath(checkquerypath), checkHash); - //console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash); + var allowedFilesFormData = {}; - // if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) { - //createContainer(containerID).then((containerName) => { + for (const [fileName, fileDetails] of Object.entries(req.files)) { + if (allowedMimeTypes.includes(fileDetails[0].headers["content-type"])) { + allowedFilesFormData[fileName] = fileDetails.map((file) => ({ + fieldName: file.fieldName, + originalFilename: file.originalFilename, + path: file.path, + size: file.size, + headers: file.headers, + contentType: file.headers["content-type"], + })); + } + } - console.log("does this get folder name:", containerID, casefolderID); + //console.log("allowedFilesFormData: ", allowedFilesFormData); - uploadSingleFile(req.files, containerID, casefolderID).then((data) => { + try { + const data = await uploadSingleFile( + allowedFilesFormData, + containerID, + casefolderID + ).then((data) => { + return res.status(200).json({ data }); + }); return res.status(200).json({ data }); - }); - - //}); - - // } else { - // return res.status(400).json(); - // } + } catch (error) { + consoleLogger(error); + return res.status(500).json({ error: "Failed to upload files" }); + } }); export const config = { From 5cadd053645ed2275e52b0d58beace4934891d6c Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 3 Feb 2025 11:54:27 +0000 Subject: [PATCH 2/6] welsh language updated for errors on uploads --- .../case/representation/representationElements.js | 12 +++++++++--- components/elements/index.js | 12 +++++++++--- data/collections.json | 3 ++- locales/cy/myrepresentations.json | 3 +++ locales/cy/newappeal.json | 3 +++ locales/en/myrepresentations.json | 3 +++ locales/en/newappeal.json | 3 +++ 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js index 8de8e02b..431e1269 100644 --- a/components/case/representation/representationElements.js +++ b/components/case/representation/representationElements.js @@ -1040,12 +1040,18 @@ export const RenderFileUpload = (field) => { .map(({ file, errors }) => { return errors.map((error) => { if (error.code === "file-too-large") { - return `${file.name} is too large. Please upload a smaller file.`; + return `${file.name} ${t( + "myrepresentations:fileupload-file-error-filesize-label" + )}`; } if (error.code === "file-invalid-type") { - return `${file.name} has an invalid type. Please upload an image.`; + return `${file.name} ${t( + "myrepresentations:fileupload-file-error-invalid-type-label" + )}`; } - return `${file.name} is invalid.`; + return `${file.name} ${t( + "myrepresentations:fileupload-file-error-invalid-label" + )}`; }); }) .flat(); // Flatten the errors array diff --git a/components/elements/index.js b/components/elements/index.js index af6f1b6f..1502943e 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -1978,12 +1978,18 @@ const RenderFileUpload = (field) => { .map(({ file, errors }) => { return errors.map((error) => { if (error.code === "file-too-large") { - return `${file.name} is too large. Please upload a smaller file.`; + return `${file.name} ${t( + "newappeal:new-appeal-fileupload-file-error-filesize-label" + )}`; } if (error.code === "file-invalid-type") { - return `${file.name} has an invalid type. Please upload an image.`; + return `${file.name} ${t( + "newappeal:new-appeal-fileupload-file-error-invalid-type-label" + )}`; } - return `${file.name} is invalid.`; + return `${file.name} ${t( + "newappeal:new-appeal-fileupload-file-error-invalid-label" + )}`; }); }) .flat(); // Flatten the errors array diff --git a/data/collections.json b/data/collections.json index fc60b0cc..3240e7c1 100644 --- a/data/collections.json +++ b/data/collections.json @@ -124,7 +124,8 @@ "UrlName": "lawfuldevelopmentcertificate", "MetadataId": "184e4861-9681-eb11-aac0-00224800be9c", "appealTypeID": "846040008", - "NavigationProperty": "pinswg_LawfulDevelopmentCertificatAppIds" + "NavigationProperty": "pinswg_LawfulDevelopmentCertificatAppIds", + "value": "Lawful Development Certificate Appeal - S194 + 195" }, { "LogicalCollectionName": "pinswg_lawfuldevelopmentcertificates", diff --git a/locales/cy/myrepresentations.json b/locales/cy/myrepresentations.json index 9f7317eb..c6dc140e 100644 --- a/locales/cy/myrepresentations.json +++ b/locales/cy/myrepresentations.json @@ -24,6 +24,9 @@ "add-files-label": "Ychwanegwch eich ffeiliau", "fileupload-drop-label": "Llusgwch a gollyngwch eich ffeiliau yma.", "fileupload-file-list-label": "Dim ond ffeiliau .pdf, .doc, .docx, .xlsx, .tif, .tiff, .jpeg, .jpg neu .zip a dderbynnir", + "fileupload-file-error-filesize-label": "yn rhy fawr. Llwythwch ffeil lai i fyny.", + "fileupload-file-error-invalid-type-label": "mae ganddo fath annilys. Uwchlwythwch fath a ganiateir.", + "fileupload-file-error-invalid-label": "yn annilys", "capacity-para-one": "Mae'r ffurflen hon yn eich galluogi i gyflwyno sylwadau ar achos i Benderfyniadau Cynllunio ac Amgylchedd Cymru", "capacity-para-two": "Sylwch fod angen cyflwyno sylwadau gan bartïon â diddordeb o fewn yr amserlen. Mae hwn i'w weld ar y dudalen \"Crynodeb Achos\" flaenorol. Gall sylwadau a gyflwynir ar ôl y dyddiad hwn gael eu hystyried yn annilys.", "capacity-select-your-details": "Eich manylion", diff --git a/locales/cy/newappeal.json b/locales/cy/newappeal.json index 6a34d353..3fc577ac 100644 --- a/locales/cy/newappeal.json +++ b/locales/cy/newappeal.json @@ -83,6 +83,9 @@ "new-appeal-procedure-option-hybrid": "Hybrid", "new-appeal-fileupload-drop-label": "Llusgwch a gollyngwch eich ffeiliau yma.", "new-appeal-fileupload-file-list-label": "Dim ond ffeiliau .pdf, .doc, .docx, .xlsx .tif, .tiff, .jpeg, .jpg neu .zip a dderbynnir", + "new-appeal-fileupload-file-error-filesize-label": "yn rhy fawr. Llwythwch ffeil lai i fyny.", + "new-appeal-fileupload-file-error-invalid-type-label": "mae ganddo fath annilys. Uwchlwythwch fath a ganiateir.", + "new-appeal-fileupload-file-error-invalid-label": "yn annilys", "s78-appeals-only-label": "Gallwch ddefnyddio'r porth hwn i gyflwyno apêl yn erbyn y canlynol yn unig:", "s78-appeals-only-bullet-one": "gwrthod caniatâd cynllunio", "s78-appeals-only-bullet-two": "methiant i benderfynu ar gais cynllunio o fewn 8 wythnos", diff --git a/locales/en/myrepresentations.json b/locales/en/myrepresentations.json index e823eb5d..9493003a 100644 --- a/locales/en/myrepresentations.json +++ b/locales/en/myrepresentations.json @@ -24,6 +24,9 @@ "add-files-label": "Add your files", "fileupload-drop-label": "Drag and drop your files here.", "fileupload-file-list-label": "Only .pdf, .doc, .docx, .xlsx, .tif, .tiff, .jpeg, .jpg or .zip files will be accepted", + "fileupload-file-error-filesize-label": "is too large. Please upload a smaller file.", + "fileupload-file-error-invalid-type-label": "has an invalid type. Please upload an allowed type.", + "fileupload-file-error-invalid-label": "is invalid", "capacity-para-one": "This form enables you to submit representations on a case to Planning and Environment Decisions Wales.", "capacity-para-two": "Please note that representations from interested parties need to be made within the timetable. This can be found on the previous \"Case Summary\" page. Representations submitted after this date may be considered invalid.", "capacity-select-your-details": "Your details", diff --git a/locales/en/newappeal.json b/locales/en/newappeal.json index 689fc3c4..0dbdb358 100644 --- a/locales/en/newappeal.json +++ b/locales/en/newappeal.json @@ -83,6 +83,9 @@ "new-appeal-procedure-option-hybrid": "Hybrid", "new-appeal-fileupload-drop-label": "Drag and drop your files here.", "new-appeal-fileupload-file-list-label": "Only .pdf, .doc, .docx, .xlsx, .tif, .tiff, .jpeg, .jpg or .zip files will be accepted", + "new-appeal-fileupload-file-error-filesize-label": "is too large. Please upload a smaller file.", + "new-appeal-fileupload-file-error-invalid-type-label": "has an invalid type. Please upload an allowed type.", + "new-appeal-fileupload-file-error-invalid-label": "is invalid", "s78-appeals-only-label": "You can only use this portal to submit an appeal against:", "s78-appeals-only-bullet-one": "a refusal of planning permission", "s78-appeals-only-bullet-two": "failure to determine a planning application within 8 weeks", From 31366f40ca1da32137791e84993ca7c701287c19 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 3 Feb 2025 13:16:02 +0000 Subject: [PATCH 3/6] reps defect 42 --- components/utils/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/utils/index.js b/components/utils/index.js index 954d662a..67841c5b 100644 --- a/components/utils/index.js +++ b/components/utils/index.js @@ -590,6 +590,7 @@ export const updateLinks = (jsonObj) => { const anchor = document.createElement("a"); anchor.href = fullUrl; anchor.textContent = match[0]; + anchor.target = "_blank"; anchor.setAttribute("rel", "noopener noreferrer"); // Add the anchor tag to the node content From c20414b32bccc32e32342239ab845ae58d0953b7 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 3 Feb 2025 13:19:59 +0000 Subject: [PATCH 4/6] uat defect 72 --- components/myportal/servicebanner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/myportal/servicebanner.js b/components/myportal/servicebanner.js index 7f411afd..dd3eee09 100644 --- a/components/myportal/servicebanner.js +++ b/components/myportal/servicebanner.js @@ -77,12 +77,12 @@ const ServiceBanner = (props) => { > {props.accountDetails.accountDetails.firstname}{" "} {props.accountDetails.accountDetails.lastname} - {" - "} + {/* {" - "} { props.accountDetails.accountDetails[ "pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue" ] - } + } */}
From f2d02dc7d37be094cfb9354b858e2ef50b5d81dc Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 3 Feb 2025 13:29:14 +0000 Subject: [PATCH 5/6] fix show hide for enf exempt fee --- ...tationLPAQuestionnaireCheck_enforcement.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js b/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js index a87db35a..683b8790 100644 --- a/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js +++ b/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js @@ -440,6 +440,43 @@ let RepLPAQuestionnaireCheck_enforcement = (props) => {
+ {repFormData.feeExempt == "Yes" && ( +
+
+ {t( + "myrepresentations:questionnaire-evidence-label" + )} +
+ +
+
+
+ +
+ { + setRepresentationSubmit(false); + setShowQuestionnaireSection(3); + }} + > + {t("common:change-link-label")} + + {" "} + {/* {FieldsTranslations( + rows[0].value + )} */} + + +
+
+ )} {/* Section 3 Planning History and Current Status */} From bedaa7928162c82ef8644bbeb46f9a34d9b912fc Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 3 Feb 2025 17:04:05 +0000 Subject: [PATCH 6/6] rep defect 42, questionnaire defect 67, enf defect 16 --- components/case/representation/index.js | 17 +++++++++-------- .../representationCompleteSubmit.js | 5 ++++- .../representation/representationElements.js | 7 ++++++- ...entationLPAQuestionnaireCheck_enforcement.js | 6 ++++-- .../representationLPAQuestionnaireCheck_s78.js | 7 +++++-- components/newappeal/buildchecksection.js | 8 +++++++- 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/components/case/representation/index.js b/components/case/representation/index.js index b060c141..f287a7b6 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -1137,14 +1137,15 @@ let MakeRepresentation = (props) => { var dataObj = values; - uploadRepFiles( - dataObj, - [{}], - values.containerID, - props.caseReference + "/" + dataObj.repfile_name - ).then((data) => { - return data; - }); + (values = updateLinks(values)), + uploadRepFiles( + dataObj, + [{}], + values.containerID, + props.caseReference + "/" + dataObj.repfile_name + ).then((data) => { + return data; + }); }; const repForm = props.props.form; diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js index 2306107e..5be1e836 100644 --- a/components/case/representation/representationCompleteSubmit.js +++ b/components/case/representation/representationCompleteSubmit.js @@ -12,6 +12,7 @@ import { bytesToSize, getThumbnailIconByExtension, formatDates, + updateLinks, } from "../../utils"; import { @@ -48,7 +49,9 @@ const RepCompleteSubmit = (props) => { )); - const repFormData = formObj.representationForm.values; + let repFormData = formObj.representationForm.values; + + repFormData = updateLinks(repFormData); //const repDate = new Date(); diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js index 431e1269..93c75517 100644 --- a/components/case/representation/representationElements.js +++ b/components/case/representation/representationElements.js @@ -38,7 +38,11 @@ import { subYears, } from "date-fns"; -import { bytesToSize, getThumbnailIconByExtension } from "../../utils"; +import { + bytesToSize, + getThumbnailIconByExtension, + updateLinks, +} from "../../utils"; import { useRouter } from "next/router"; @@ -783,6 +787,7 @@ export const RenderRichMultiline = ({ ); const changeEdit = (valStr) => { + valStr = updateLinks(valStr); setEditValue(valStr); input.onChange(valStr); }; diff --git a/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js b/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js index 683b8790..be6afddd 100644 --- a/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js +++ b/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement.js @@ -1,6 +1,6 @@ import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; -import { formatDates } from "../../../utils"; +import { formatDates, updateLinks } from "../../../utils"; let RepLPAQuestionnaireCheck_enforcement = (props) => { let { t } = useTranslation(); @@ -14,7 +14,9 @@ let RepLPAQuestionnaireCheck_enforcement = (props) => { questionnaireCount, } = props; - const repFormData = formObj.representationForm.values; + let repFormData = formObj.representationForm.values; + + repFormData = updateLinks(repFormData); return ( <> diff --git a/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_s78.js b/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_s78.js index eae18fe3..9502e638 100644 --- a/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_s78.js +++ b/components/case/representation/representationQuestionnairesCheck/representationLPAQuestionnaireCheck_s78.js @@ -1,6 +1,6 @@ import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; -import { formatDates } from "../../../utils"; +import { formatDates, updateLinks } from "../../../utils"; let RepLPAQuestionnaireCheck_s78 = (props) => { let { t } = useTranslation(); @@ -13,7 +13,10 @@ let RepLPAQuestionnaireCheck_s78 = (props) => { setRepresentationSubmit, questionnaireCount, } = props; - const repFormData = formObj.representationForm.values; + + let repFormData = formObj.representationForm.values; + + repFormData = updateLinks(formObj); return ( <> diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js index d34f106f..ea5d2c9c 100644 --- a/components/newappeal/buildchecksection.js +++ b/components/newappeal/buildchecksection.js @@ -14,7 +14,11 @@ import { import BuildCheckRow from "./buildcheckrow"; import { generateAppealPDF, sendCaseCompleteMessage } from "../../actions"; -import { bytesToSize, getThumbnailIconByExtension } from "../utils"; +import { + bytesToSize, + getThumbnailIconByExtension, + updateLinks, +} from "../utils"; let BuildCheckSection = (props) => { useEffect(() => { @@ -107,6 +111,8 @@ let BuildCheckSection = (props) => { let pdfObj = props.props.form.appealForm.values; + pdfObj = updateLinks(pdfObj); + Object.assign(pdfObj, { "filesList": buildAppealFilesArray, "containerID": props.props.accountDetails.containerID,