@@ -37,3 +37,5 @@ pages/polling.js
|
|||||||
|
|
||||||
/pages/api/endpoint/getaccounts_api.js
|
/pages/api/endpoint/getaccounts_api.js
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -367,6 +367,13 @@ let MakeRepresentation = (props) => {
|
|||||||
todaysDate <= finalCommentsDate &&
|
todaysDate <= finalCommentsDate &&
|
||||||
buildArr.push("Local Impact Report");
|
buildArr.push("Local Impact Report");
|
||||||
|
|
||||||
|
isLPA &&
|
||||||
|
isDNS &&
|
||||||
|
currentView.caseReference.appealType != 846040019 &&
|
||||||
|
todaysDate >= startDate &&
|
||||||
|
todaysDate <= finalCommentsDate &&
|
||||||
|
buildArr.push("Statement");
|
||||||
|
|
||||||
!isDNS &&
|
!isDNS &&
|
||||||
currentView.caseReference.appealType != 846040004 &&
|
currentView.caseReference.appealType != 846040004 &&
|
||||||
todaysDate >= startDate &&
|
todaysDate >= startDate &&
|
||||||
@@ -772,10 +779,15 @@ let MakeRepresentation = (props) => {
|
|||||||
props.props.currentView.caseReference.currentReference,
|
props.props.currentView.caseReference.currentReference,
|
||||||
"pinswg_questionnaireduedate":
|
"pinswg_questionnaireduedate":
|
||||||
detailsObj.pinswg_questionnaireduedate,
|
detailsObj.pinswg_questionnaireduedate,
|
||||||
"pinswg_statementduedate": detailsObj.pinswg_statementduedate,
|
"pinswg_statementduedate":
|
||||||
"pinswg_statementsduedate": detailsObj.pinswg_statementsduedate,
|
detailsObj.pinswg_statementduedate ||
|
||||||
|
detailsObj.pinswg_endofrepresentationperiod,
|
||||||
|
"pinswg_statementsduedate":
|
||||||
|
detailsObj.pinswg_statementsduedate ||
|
||||||
|
detailsObj.pinswg_endofrepresentationperiod,
|
||||||
"pinswg_finalcommentsduedate":
|
"pinswg_finalcommentsduedate":
|
||||||
detailsObj.pinswg_finalcommentsduedate,
|
detailsObj.pinswg_finalcommentsduedate ||
|
||||||
|
detailsObj.pinswg_endofrepresentationperiod,
|
||||||
"pinswg_name":
|
"pinswg_name":
|
||||||
props.props.currentView.caseReference.currentReference,
|
props.props.currentView.caseReference.currentReference,
|
||||||
"firstname": props.props.accountDetails.accountDetails.firstname,
|
"firstname": props.props.accountDetails.accountDetails.firstname,
|
||||||
|
|||||||
@@ -944,8 +944,10 @@ export const RenderFileUpload = (field) => {
|
|||||||
return "/assets/images/documenttypes/zip.png";
|
return "/assets/images/documenttypes/zip.png";
|
||||||
break;
|
break;
|
||||||
case "image/jpeg":
|
case "image/jpeg":
|
||||||
|
return "/assets/images/documenttypes/jpg.png";
|
||||||
case "image/png":
|
case "image/png":
|
||||||
return URL.createObjectURL(fileObj);
|
return "/assets/images/documenttypes/jpg.png";
|
||||||
|
//return URL.createObjectURL(fileObj);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return "/assets/images/documenttypes/default.png";
|
return "/assets/images/documenttypes/default.png";
|
||||||
@@ -1074,6 +1076,7 @@ export const RenderFileUpload = (field) => {
|
|||||||
|
|
||||||
// Handle accepted files (clear error message when files are accepted)
|
// Handle accepted files (clear error message when files are accepted)
|
||||||
const handleDropAccepted = () => {
|
const handleDropAccepted = () => {
|
||||||
|
setErrorMessage(null);
|
||||||
setRejectedFiles([]); // Clear any previously rejected file errorsss
|
setRejectedFiles([]); // Clear any previously rejected file errorsss
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1169,6 +1172,12 @@ export const RenderFileUpload = (field) => {
|
|||||||
// Object.assign(values, {
|
// Object.assign(values, {
|
||||||
// "fileList": buildAppealFilesArray,
|
// "fileList": buildAppealFilesArray,
|
||||||
// });
|
// });
|
||||||
|
data.invalidFiles.length > 0 &&
|
||||||
|
(setRejectedFiles(data.invalidFiles),
|
||||||
|
setUploadCountMessage(
|
||||||
|
renamedAcceptedFiles.length -
|
||||||
|
data.invalidFiles.length
|
||||||
|
));
|
||||||
getFilesFromBlobproxy(
|
getFilesFromBlobproxy(
|
||||||
field.containerID,
|
field.containerID,
|
||||||
field.ticketnumber +
|
field.ticketnumber +
|
||||||
@@ -1215,32 +1224,16 @@ export const RenderFileUpload = (field) => {
|
|||||||
)
|
)
|
||||||
</em>
|
</em>
|
||||||
</div>
|
</div>
|
||||||
<aside>{thumbs}</aside>
|
{/* <aside>{thumbs}</aside> */}
|
||||||
{uploadCountMessage > 0 &&
|
|
||||||
completedUploadFiles == false && (
|
|
||||||
<div className="govuk-body govuk-!-font-size-14">
|
|
||||||
{t("home:uploading-files-label", {
|
|
||||||
number: uploadCountMessage,
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{completedUploadFiles > 0 &&
|
|
||||||
uploadCountMessage > 0 && (
|
|
||||||
<div className="govuk-body govuk-!-font-size-14">
|
|
||||||
{t(
|
|
||||||
"home:completed-uploading-files-label",
|
|
||||||
{
|
|
||||||
number: uploadCountMessage,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</section>
|
</section>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Dropzone>
|
</Dropzone>
|
||||||
{rejectedFiles.length > 0 && (
|
{rejectedFiles.length > 0 && completedUploadFiles == true && (
|
||||||
<div style={{ color: "red", marginTop: "10px" }}>
|
<div
|
||||||
|
style={{ color: "red", marginTop: "10px" }}
|
||||||
|
className="govuk-body govuk-!-font-size-14 "
|
||||||
|
>
|
||||||
<ul>
|
<ul>
|
||||||
{rejectedFiles.map((error, index) => (
|
{rejectedFiles.map((error, index) => (
|
||||||
<li key={index}>{error}</li>
|
<li key={index}>{error}</li>
|
||||||
@@ -1248,6 +1241,20 @@ export const RenderFileUpload = (field) => {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{uploadCountMessage > 0 && completedUploadFiles == false && (
|
||||||
|
<div className="govuk-body govuk-!-font-size-14">
|
||||||
|
{t("home:uploading-files-label", {
|
||||||
|
number: uploadCountMessage,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{completedUploadFiles > 0 && uploadCountMessage >= 0 && (
|
||||||
|
<div className="govuk-body govuk-!-font-size-14">
|
||||||
|
{t("home:completed-uploading-files-label", {
|
||||||
|
number: uploadCountMessage,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{field.meta.touched && field.meta.error && (
|
{field.meta.touched && field.meta.error && (
|
||||||
<span className="error">{field.meta.error}</span>
|
<span className="error">{field.meta.error}</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1851,8 +1851,10 @@ const RenderFileUpload = (field) => {
|
|||||||
return "/assets/images/documenttypes/zip.png";
|
return "/assets/images/documenttypes/zip.png";
|
||||||
break;
|
break;
|
||||||
case "image/jpeg":
|
case "image/jpeg":
|
||||||
|
return "/assets/images/documenttypes/jpg.png";
|
||||||
case "image/png":
|
case "image/png":
|
||||||
return URL.createObjectURL(fileObj);
|
return "/assets/images/documenttypes/png.png";
|
||||||
|
//return URL.createObjectURL(fileObj);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return "/assets/images/documenttypes/default.png";
|
return "/assets/images/documenttypes/default.png";
|
||||||
@@ -2036,13 +2038,12 @@ const RenderFileUpload = (field) => {
|
|||||||
);
|
);
|
||||||
field.input.onChange(renamedAcceptedFiles);
|
field.input.onChange(renamedAcceptedFiles);
|
||||||
|
|
||||||
setUploadCountMessage(renamedAcceptedFiles.length);
|
|
||||||
|
|
||||||
console.log("werwerw");
|
|
||||||
field.setFileCount(
|
field.setFileCount(
|
||||||
field.uploadCount + renamedAcceptedFiles.length
|
field.uploadCount + renamedAcceptedFiles.length
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setUploadCountMessage(renamedAcceptedFiles.length);
|
||||||
|
|
||||||
uploadSingleFile(
|
uploadSingleFile(
|
||||||
renamedAcceptedFiles,
|
renamedAcceptedFiles,
|
||||||
field.containerID,
|
field.containerID,
|
||||||
@@ -2089,6 +2090,12 @@ const RenderFileUpload = (field) => {
|
|||||||
Object.assign(values, {
|
Object.assign(values, {
|
||||||
"filesList": buildAppealFilesArray,
|
"filesList": buildAppealFilesArray,
|
||||||
});
|
});
|
||||||
|
data.invalidFiles.length > 0 &&
|
||||||
|
(setRejectedFiles(data.invalidFiles),
|
||||||
|
setUploadCountMessage(
|
||||||
|
renamedAcceptedFiles.length -
|
||||||
|
data.invalidFiles.length
|
||||||
|
));
|
||||||
getFilesFromBlobproxy(
|
getFilesFromBlobproxy(
|
||||||
field.containerID,
|
field.containerID,
|
||||||
field.ticketnumber
|
field.ticketnumber
|
||||||
@@ -2123,31 +2130,15 @@ const RenderFileUpload = (field) => {
|
|||||||
</em>
|
</em>
|
||||||
</div>
|
</div>
|
||||||
{/* <aside>{thumbs}</aside> */}
|
{/* <aside>{thumbs}</aside> */}
|
||||||
{uploadCountMessage > 0 &&
|
|
||||||
completedUploadFiles == false && (
|
|
||||||
<div className="govuk-body govuk-!-font-size-14">
|
|
||||||
{t("home:uploading-files-label", {
|
|
||||||
number: uploadCountMessage,
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{completedUploadFiles > 0 &&
|
|
||||||
uploadCountMessage > 0 && (
|
|
||||||
<div className="govuk-body govuk-!-font-size-14">
|
|
||||||
{t(
|
|
||||||
"home:completed-uploading-files-label",
|
|
||||||
{
|
|
||||||
number: uploadCountMessage,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</section>
|
</section>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Dropzone>
|
</Dropzone>
|
||||||
{rejectedFiles.length > 0 && (
|
{rejectedFiles.length > 0 && completedUploadFiles == true && (
|
||||||
<div style={{ color: "red", marginTop: "10px" }}>
|
<div
|
||||||
|
style={{ color: "red", marginTop: "10px" }}
|
||||||
|
className="govuk-body govuk-!-font-size-14 "
|
||||||
|
>
|
||||||
<ul>
|
<ul>
|
||||||
{rejectedFiles.map((error, index) => (
|
{rejectedFiles.map((error, index) => (
|
||||||
<li key={index}>{error}</li>
|
<li key={index}>{error}</li>
|
||||||
@@ -2155,6 +2146,20 @@ const RenderFileUpload = (field) => {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{uploadCountMessage > 0 && completedUploadFiles == false && (
|
||||||
|
<div className="govuk-body govuk-!-font-size-14">
|
||||||
|
{t("home:uploading-files-label", {
|
||||||
|
number: uploadCountMessage,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{completedUploadFiles > 0 && uploadCountMessage >= 0 && (
|
||||||
|
<div className="govuk-body govuk-!-font-size-14">
|
||||||
|
{t("home:completed-uploading-files-label", {
|
||||||
|
number: uploadCountMessage,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{field.meta.touched && field.meta.error && (
|
{field.meta.touched && field.meta.error && (
|
||||||
<span className="error">{field.meta.error}</span>
|
<span className="error">{field.meta.error}</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
+63
-15
@@ -1,3 +1,4 @@
|
|||||||
|
import { he } from "date-fns/locale";
|
||||||
import GoogleMapReact from "google-map-react";
|
import GoogleMapReact from "google-map-react";
|
||||||
const GoogleMapComponent = (props) => {
|
const GoogleMapComponent = (props) => {
|
||||||
const { center, zoom } = props;
|
const { center, zoom } = props;
|
||||||
@@ -21,22 +22,69 @@ const GoogleMapComponent = (props) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// console.log(
|
||||||
|
// "https://datamap.gov.wales/maps/pedw-dev/embed?center=" +
|
||||||
|
// props.center.lng +
|
||||||
|
// "," +
|
||||||
|
// props.center.lat +
|
||||||
|
// "&zoom=12#/"
|
||||||
|
// );
|
||||||
return (
|
return (
|
||||||
<GoogleMapReact
|
// <GoogleMapReact
|
||||||
options={function (maps) {
|
// options={function (maps) {
|
||||||
return {
|
// return {
|
||||||
overviewMapControl: true,
|
// overviewMapControl: true,
|
||||||
mapTypeControl: true,
|
// mapTypeControl: true,
|
||||||
};
|
// };
|
||||||
}}
|
// }}
|
||||||
bootstrapURLKeys={{
|
// bootstrapURLKeys={{
|
||||||
key: "AIzaSyCzeVrHt544bp_72YCFkw21eDsmI2JEsQo",
|
// key: "AIzaSyCzeVrHt544bp_72YCFkw21eDsmI2JEsQo",
|
||||||
}}
|
// }}
|
||||||
defaultCenter={center}
|
// defaultCenter={center}
|
||||||
defaultZoom={zoom}
|
// defaultZoom={zoom}
|
||||||
yesIWantToUseGoogleMapApiInternals
|
// yesIWantToUseGoogleMapApiInternals
|
||||||
onGoogleApiLoaded={({ map, maps }) => ModelsMap(map, maps)}
|
// onGoogleApiLoaded={({ map, maps }) => ModelsMap(map, maps)}
|
||||||
></GoogleMapReact>
|
// ></GoogleMapReact>
|
||||||
|
<>
|
||||||
|
{" "}
|
||||||
|
<div className="govuk-grid-row">
|
||||||
|
<div className="govuk-grid-column-full">
|
||||||
|
<a
|
||||||
|
href={
|
||||||
|
"https://datamap.gov.wales/maps/pedw-dev/embed?center=" +
|
||||||
|
props.center.lng +
|
||||||
|
"," +
|
||||||
|
props.center.lat +
|
||||||
|
"&zoom=7#/"
|
||||||
|
}
|
||||||
|
rel="noreferrer noopener"
|
||||||
|
className="govuk-link govuk-link--no-underline govuk-!-font-size-14 "
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
See this map on Datamap Wales
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="govuk-grid-row">
|
||||||
|
<div className="govuk-grid-column-full">
|
||||||
|
<iframe
|
||||||
|
src={
|
||||||
|
"https://datamap.gov.wales/maps/pedw-dev/embed?center=" +
|
||||||
|
props.center.lng +
|
||||||
|
"," +
|
||||||
|
props.center.lat +
|
||||||
|
"&zoom=7#/"
|
||||||
|
}
|
||||||
|
//src={"https://datamap.gov.wales/maps/pedw-dev/embed#/"}
|
||||||
|
width={"100%"}
|
||||||
|
maxheight={"400px"}
|
||||||
|
height={"500px"}
|
||||||
|
className={"mappingFrame"}
|
||||||
|
></iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -580,10 +580,10 @@ let AdvancedSearch = (props) => {
|
|||||||
label={t("search:appealtype-label")}
|
label={t("search:appealtype-label")}
|
||||||
errormsg="Appeal type is required"
|
errormsg="Appeal type is required"
|
||||||
/>
|
/>
|
||||||
{props.props?.props.form[
|
|
||||||
props.form
|
{props.appealTypesValue?.split(
|
||||||
]?.values?.appealTypes.split(",")[0] ===
|
","
|
||||||
"846040002" && (
|
)[0] === "846040002" && (
|
||||||
<Field
|
<Field
|
||||||
name="projecttype"
|
name="projecttype"
|
||||||
id="projecttype"
|
id="projecttype"
|
||||||
@@ -778,6 +778,14 @@ const mapDispatchToProps = (dispatch) => {
|
|||||||
|
|
||||||
const selector = formValueSelector("advancedSearchForm"); // <-- same as form name
|
const selector = formValueSelector("advancedSearchForm"); // <-- same as form name
|
||||||
|
|
||||||
|
AdvancedSearch = connect((state) => {
|
||||||
|
const appealTypesValue = selector(state, "appealTypes");
|
||||||
|
|
||||||
|
return {
|
||||||
|
appealTypesValue,
|
||||||
|
};
|
||||||
|
})(AdvancedSearch);
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
|
|||||||
@@ -753,12 +753,12 @@ const DNSSearchResults = (props) => {
|
|||||||
{showMap == "true" && (
|
{showMap == "true" && (
|
||||||
<div className="govuk-grid-column-one-half">
|
<div className="govuk-grid-column-one-half">
|
||||||
<div
|
<div
|
||||||
style={{
|
// style={{
|
||||||
height: "45vh",
|
// height: "45vh",
|
||||||
width: "100%",
|
// width: "100%",
|
||||||
}}
|
// }}
|
||||||
>
|
>
|
||||||
<GoogleMapReact
|
{/* <GoogleMapReact
|
||||||
options={function (maps) {
|
options={function (maps) {
|
||||||
return {
|
return {
|
||||||
overviewMapControl: true,
|
overviewMapControl: true,
|
||||||
@@ -777,7 +777,18 @@ const DNSSearchResults = (props) => {
|
|||||||
onGoogleApiLoaded={({ map, maps }) =>
|
onGoogleApiLoaded={({ map, maps }) =>
|
||||||
ModelsMap(map, maps)
|
ModelsMap(map, maps)
|
||||||
}
|
}
|
||||||
/>
|
/> */}
|
||||||
|
|
||||||
|
<iframe
|
||||||
|
src={
|
||||||
|
"https://datamap.gov.wales/maps/pedw-dev/embed?center=-3.6553189192727347,52.214962933659415&zoom=2#/"
|
||||||
|
}
|
||||||
|
//src={"https://datamap.gov.wales/maps/pedw-dev/embed#/"}
|
||||||
|
width={"100%"}
|
||||||
|
maxheight={"400px"}
|
||||||
|
height={"500px"}
|
||||||
|
className={"mappingFrame"}
|
||||||
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
"date-fns": "^2.30.0",
|
"date-fns": "^2.30.0",
|
||||||
"dom": "^0.0.3",
|
"dom": "^0.0.3",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"file-type": "^20.4.1",
|
||||||
"fs": "0.0.2",
|
"fs": "0.0.2",
|
||||||
"google-map-react": "^2.2.1",
|
"google-map-react": "^2.2.1",
|
||||||
"govuk-frontend": "^5.0.0",
|
"govuk-frontend": "^5.0.0",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class MyDocument extends Document {
|
|||||||
csp += `style-src 'self' 'unsafe-inline' https://pro.fontawesome.com/ https://www.google-analytics.com https://tagmanager.google.com/ https://www.googletagmanager.com/ https://fonts.googleapis.com/;`;
|
csp += `style-src 'self' 'unsafe-inline' https://pro.fontawesome.com/ https://www.google-analytics.com https://tagmanager.google.com/ https://www.googletagmanager.com/ https://fonts.googleapis.com/;`;
|
||||||
csp += `img-src 'self' 'unsafe-inline' https://maps.gstatic.com https://maps.googleapis.com https://www.gov.wales https://gov.wales https://fonts.gstatic.com https://www.googletagmanager.com https://www.google-analytics.com https://ssl.gstatic.com/ blob: data:;`;
|
csp += `img-src 'self' 'unsafe-inline' https://maps.gstatic.com https://maps.googleapis.com https://www.gov.wales https://gov.wales https://fonts.gstatic.com https://www.googletagmanager.com https://www.google-analytics.com https://ssl.gstatic.com/ blob: data:;`;
|
||||||
csp += `font-src 'self' 'unsafe-inline' https://pro.fontawesome.com/ https://fonts.gstatic.com/ data:;`;
|
csp += `font-src 'self' 'unsafe-inline' https://pro.fontawesome.com/ https://fonts.gstatic.com/ data:;`;
|
||||||
|
csp += `frame-src https://datamap.gov.wales`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Html lang={locale}>
|
<Html lang={locale}>
|
||||||
|
|||||||
@@ -21,6 +21,70 @@ const hashAPIPath = (queryPath) => {
|
|||||||
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renameKeys = (obj) => {
|
||||||
|
const keyMappings = {
|
||||||
|
"pinswg_projectlocation": "location",
|
||||||
|
"pinswg_mapzoomlevel": "zoomLevel",
|
||||||
|
"pinswg_name": "projectName",
|
||||||
|
"pinswg_anticipatedgridreferenceeastingtext": "easting",
|
||||||
|
"pinswg_anticipatedgridreferencenorthingtext": "northing",
|
||||||
|
"pinswg_anticipatedgridrefeasting": "easting",
|
||||||
|
"pinswg_anticipatedgridrefnorthing": "northing",
|
||||||
|
"pinswg_projectname": "projectTitle",
|
||||||
|
"pinswg_dnsid": "dnsId",
|
||||||
|
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue":
|
||||||
|
"lpaDisplayName",
|
||||||
|
"_pinswg_associatedlpa_value": "lpaId",
|
||||||
|
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue":
|
||||||
|
"appellantDisplayName",
|
||||||
|
"_pinswg_appellant_value": "appellantId",
|
||||||
|
"zoom": "mapZoom",
|
||||||
|
"center": "locationCenter",
|
||||||
|
};
|
||||||
|
|
||||||
|
let renamedObj = {};
|
||||||
|
Object.keys(obj).forEach((key) => {
|
||||||
|
// Skip keys that need to be removed
|
||||||
|
if (keysToRemove.includes(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the key exists in the mapping
|
||||||
|
if (keyMappings[key]) {
|
||||||
|
renamedObj[keyMappings[key]] = obj[key];
|
||||||
|
} else {
|
||||||
|
renamedObj[key] = obj[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Recursively rename keys in nested objects
|
||||||
|
if (obj.center) {
|
||||||
|
renamedObj.locationCenter = {
|
||||||
|
lat: obj.center.lat,
|
||||||
|
lng: obj.center.lng,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renamedObj.easting) {
|
||||||
|
renamedObj.easting = String(renamedObj.easting);
|
||||||
|
}
|
||||||
|
if (renamedObj.northing) {
|
||||||
|
renamedObj.northing = String(renamedObj.northing);
|
||||||
|
}
|
||||||
|
|
||||||
|
return renamedObj;
|
||||||
|
};
|
||||||
|
|
||||||
|
const keysToRemove = [
|
||||||
|
"_pinswg_associatedlpa_value@Microsoft.Dynamics.CRM.associatednavigationproperty",
|
||||||
|
"_pinswg_appellant_value@Microsoft.Dynamics.CRM.associatednavigationproperty",
|
||||||
|
"_pinswg_associatedlpa_value@Microsoft.Dynamics.CRM.lookuplogicalname",
|
||||||
|
"_pinswg_appellant_value@Microsoft.Dynamics.CRM.lookuplogicalname",
|
||||||
|
"pinswg_anticipatedgridrefeasting@OData.Community.Display.V1.FormattedValue",
|
||||||
|
"pinswg_anticipatedgridrefnorthing@OData.Community.Display.V1.FormattedValue",
|
||||||
|
// Add any other keys to remove here
|
||||||
|
];
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
var token = await getToken();
|
var token = await getToken();
|
||||||
|
|
||||||
@@ -90,7 +154,15 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Send the merged values as the response
|
// Send the merged values as the response
|
||||||
return res.status(200).json(coordsObj);
|
|
||||||
|
const updatedData = {
|
||||||
|
value: coordsObj.value.map((item) => renameKeys(item)),
|
||||||
|
"@odata.count": coordsObj["@odata.count"],
|
||||||
|
};
|
||||||
|
|
||||||
|
return req.query.hasOwnProperty("fordmw")
|
||||||
|
? res.status(200).json(updatedData)
|
||||||
|
: res.status(200).json(coordsObj);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Catch any errors and send an error response
|
// Catch any errors and send an error response
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import {
|
|||||||
import nextConnect from "next-connect";
|
import nextConnect from "next-connect";
|
||||||
import middleware from "../middleware/middleware";
|
import middleware from "../middleware/middleware";
|
||||||
import { consoleLogger } from "../../../actions";
|
import { consoleLogger } from "../../../actions";
|
||||||
|
import { fileTypeFromBuffer } from "file-type";
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
const ApiProxy = nextConnect();
|
const ApiProxy = nextConnect();
|
||||||
ApiProxy.use(middleware);
|
ApiProxy.use(middleware);
|
||||||
@@ -35,31 +38,99 @@ ApiProxy.post(async (req, res) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
var allowedFilesFormData = {};
|
var allowedFilesFormData = {};
|
||||||
|
var invalidFiles = []; // To store the names of invalid files
|
||||||
|
|
||||||
|
// 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"],
|
||||||
|
// }));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
for (const [fileName, fileDetails] of Object.entries(req.files)) {
|
for (const [fileName, fileDetails] of Object.entries(req.files)) {
|
||||||
if (allowedMimeTypes.includes(fileDetails[0].headers["content-type"])) {
|
const file = fileDetails[0];
|
||||||
allowedFilesFormData[fileName] = fileDetails.map((file) => ({
|
const filePath = file.path;
|
||||||
fieldName: file.fieldName,
|
|
||||||
originalFilename: file.originalFilename,
|
// Check the MIME type from file headers
|
||||||
path: file.path,
|
const fileMimeType = file.headers["content-type"];
|
||||||
size: file.size,
|
if (allowedMimeTypes.includes(fileMimeType)) {
|
||||||
headers: file.headers,
|
// Check file signature (magic number) using file-type
|
||||||
contentType: file.headers["content-type"],
|
const buffer = fs.readFileSync(filePath);
|
||||||
}));
|
|
||||||
|
try {
|
||||||
|
const type = await fileTypeFromBuffer(buffer); // Correct usage of fileTypeFromBuffer
|
||||||
|
console.log("checking mime type ", type);
|
||||||
|
if (type && allowedMimeTypes.includes(type.mime)) {
|
||||||
|
// If the MIME type from the file signature matches the allowed list
|
||||||
|
allowedFilesFormData[fileName] = fileDetails.map(
|
||||||
|
(file) => ({
|
||||||
|
fieldName: file.fieldName,
|
||||||
|
originalFilename: file.originalFilename,
|
||||||
|
path: file.path,
|
||||||
|
size: file.size,
|
||||||
|
headers: file.headers,
|
||||||
|
contentType: fileMimeType,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\nFile ${fileName} has an invalid MIME type based on its content.\n\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`
|
||||||
|
);
|
||||||
|
invalidFiles.push(fileName); // Track invalid file
|
||||||
|
|
||||||
|
// return res
|
||||||
|
// .status(400)
|
||||||
|
// .json({ error: `Invalid file type for ${fileName}` });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(
|
||||||
|
`Error reading file ${fileName} for MIME type validation`,
|
||||||
|
error
|
||||||
|
);
|
||||||
|
// return res
|
||||||
|
// .status(500)
|
||||||
|
// .json({ error: "Failed to validate file type" });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\nFile ${fileName} has an unsupported MIME type: ${fileMimeType}\n\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`
|
||||||
|
);
|
||||||
|
invalidFiles.push(fileName); // Track invalid file
|
||||||
|
|
||||||
|
// return res.status(400).json({
|
||||||
|
// error: `Unsupported MIME type for ${fileName}`,
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log("allowedFilesFormData: ", allowedFilesFormData);
|
//console.log("allowedFilesFormData: ", allowedFilesFormData);
|
||||||
|
|
||||||
|
// If no valid files are found
|
||||||
|
// if (Object.keys(allowedFilesFormData).length === 0) {
|
||||||
|
// return res.status(400).json({
|
||||||
|
// error: "No valid files found",
|
||||||
|
// invalidFiles: invalidFiles, // Return the list of invalid files
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
invalidFiles = invalidFiles.map((fileName) => {
|
||||||
|
return `${fileName} - Invalid file`;
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await uploadSingleFile(
|
const data = await uploadSingleFile(
|
||||||
allowedFilesFormData,
|
allowedFilesFormData,
|
||||||
containerID,
|
containerID,
|
||||||
casefolderID
|
casefolderID
|
||||||
).then((data) => {
|
).then((data) => {
|
||||||
return res.status(200).json({ data });
|
return res.status(200).json({ data, invalidFiles });
|
||||||
});
|
});
|
||||||
return res.status(200).json({ data });
|
return res.status(200).json({ data, invalidFiles });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
return res.status(500).json({ error: "Failed to upload files" });
|
return res.status(500).json({ error: "Failed to upload files" });
|
||||||
|
|||||||
@@ -1936,6 +1936,11 @@ ul#sharePageLinks.active {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.mappingFrame {
|
||||||
|
border: 1px solid $lightgrey
|
||||||
|
}
|
||||||
|
|
||||||
//dns application view
|
//dns application view
|
||||||
|
|
||||||
.govuk-warning-text__icon {
|
.govuk-warning-text__icon {
|
||||||
|
|||||||
Reference in New Issue
Block a user