Merged PR 1406: PII-UAT defects anf ITHC fix for upload via api

Related work items: #12956
This commit is contained in:
Robert Bond
2025-02-03 17:06:16 +00:00
15 changed files with 148 additions and 41 deletions
+9 -8
View File
@@ -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;
@@ -12,6 +12,7 @@ import {
bytesToSize,
getThumbnailIconByExtension,
formatDates,
updateLinks,
} from "../../utils";
import {
@@ -48,7 +49,9 @@ const RepCompleteSubmit = (props) => {
</li>
));
const repFormData = formObj.representationForm.values;
let repFormData = formObj.representationForm.values;
repFormData = updateLinks(repFormData);
//const repDate = new Date();
@@ -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);
};
@@ -1040,12 +1045,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
@@ -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 (
<>
@@ -440,6 +442,43 @@ let RepLPAQuestionnaireCheck_enforcement = (props) => {
</a>
</dd>
</div>
{repFormData.feeExempt == "Yes" && (
<div className="govuk-summary-list__row">
<dt className="govuk-summary-list__key">
{t(
"myrepresentations:questionnaire-evidence-label"
)}
</dt>
<dd className="govuk-summary-list__value">
<div
className="govuk-summary-list-check-ellipsis"
dangerouslySetInnerHTML={{
__html: repFormData.feeExemptEvidence,
}}
/>
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
setRepresentationSubmit(false);
setShowQuestionnaireSection(3);
}}
>
{t("common:change-link-label")}
<span className="govuk-visually-hidden">
{" "}
{/* {FieldsTranslations(
rows[0].value
)} */}
</span>
</a>
</dd>
</div>
)}
</>
</>
{/* Section 3 Planning History and Current Status */}
@@ -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 (
<>
+9 -3
View File
@@ -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
+2 -2
View File
@@ -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"
]
}
} */}
</Link>
</div>
<div>
+7 -1
View File
@@ -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,
+1
View File
@@ -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
+2 -1
View File
@@ -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",
+3
View File
@@ -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",
+3
View File
@@ -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",
+3
View File
@@ -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",
+3
View File
@@ -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",
+41 -17
View File
@@ -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 = {