diff --git a/actions/azurestorage.js b/actions/azurestorage.js index 472a806f..0fa715b0 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -1270,7 +1270,21 @@ export const getAllProgressBlobs = async (containerName) => { // "\n////////////////////////////" // ); - return blobObj; + function removeDuplicates(arr) { + const unique = arr.filter( + (value, index, self) => + index === + self.findIndex( + (t) => + t.name === value.name // Change 'id' to the property you're checking for uniqueness + ) + ); + return unique; + } + + const result = removeDuplicates(blobObj); + + return result; }; export const getRepsBlobs = async (containerName) => { diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 0071b180..06faf301 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -865,50 +865,23 @@ let MakeRepresentation = (props) => { ? (Object.assign(values, { "filesList": props.currentView.fileList, }), - // commented out as dont need to create pdf on save - // generateRepPDF( - // values, - // props.props.accountDetails.containerID, - // currentView.caseReference.currentReference - // ), uploadRepresentationFiles(values), router.replace( router.locale != "en" ? router.locale + "/myportal" : "/myportal" )) - : //values.hasOwnProperty("representationDocuments") && - // sortFileObj() - // (values.representationDocuments.map((Blob) => - // buildFileArray.push({ - // "name": Blob.name, - // "size": Blob.size, - // }) - // ), - // Object.assign(values, { - // "filesList": buildFileArray, - // })), - console.log("updated"); - uploadRepresentationFiles(values); - // generateRepPDF( - // values, - // props.props.accountDetails.containerID, - // currentView.caseReference.currentReference - // ); + : Object.assign(values, { + "filesList": props.currentView.fileList, + }), + console.log("Rep Updated - props.caseReference"), + uploadRepresentationFiles(values); }; const onHandleSubmit = (values) => { window.scrollTo({ top: 0, behavior: "smooth" }); values = setRepFileName(values); - // values.representationType == "Questionnaire" && - // !values.hasOwnProperty("pinswg_lpareference") && - // Object.assign(values, { - // "pinswg_lpareference": - // searchResultsObj?.searchResultsObj?.value[0] - // ?.pinswg_lpareference, - // }); - //console.log("onHandleSubmit form values - ", JSON.stringify(values)); const buildFileArray = []; @@ -1074,55 +1047,9 @@ let MakeRepresentation = (props) => { setRepresentationSubmit(true); setRepresentationSubmitConfirmation(true); } else { - console.log("nit updated"); + console.log("not updated"); } } - - // currentView.representationSubmit != true - // ? _.isEmpty(currentView.representationCapacity) - // ? isLPA - // ? setRepresentationCapacity("LPA") - // : setRepresentationCapacity( - // values.representationCapacity - // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") - // .toLowerCase() - // ) - // : questionnaireCount != 0 && - // showQuestionnaireSection < questionnaireCount - // ? (setShowQuestionnaireSection(showQuestionnaireSection + 1), - // updateRepresentation(values, false, false)) - // : (updateRepresentation(values, false, false), - // setRepresentationSubmit(true)) - // : currentView.representationSubmit == true - // ? (console.log("capacity", currentView.representationCapacity), - // console.log("has errors:", props.invalid), - // Object.assign(values, { "locale": router.locale }), - // props.invalid == false && - // updateRepresentation(values, false, false), - // // values.hasOwnProperty("representationDocuments") && - // // (values.representationDocuments.map((Blob) => - // // buildFileArray.push({ - // // "name": Blob.name, - // // "size": Blob.size, - // // }) - // // ), - // // Object.assign(values, { - // // "filesList": buildFileArray, - // // })), - // console.log( - // "====================== rep lpa payload:\n", - // JSON.stringify(values) - // ), - // generateRepPDF( - // values, - // props.props.accountDetails.containerID, - // currentView.caseReference.currentReference - // ), - // uploadRepresentationFiles(values), - // setRepresentationSubmitConfirmation(true)) - // : console.log("nit updated"); - - //window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`); }; const cleanFilesList = (blobList) => { @@ -1184,14 +1111,9 @@ let MakeRepresentation = (props) => { var dataObj = values; - // for (let key in dataObj) { - // _.includes(key, "representationDocuments") == true && - // delete dataObj[key]; - // } - uploadRepFiles( dataObj, - fileListObj, + [{}], values.containerID, props.caseReference + "/" + dataObj.repfile_name ).then((data) => { @@ -1229,140 +1151,103 @@ let MakeRepresentation = (props) => { /> ) : ( <> - {/* {!session ? ( - <> -
- {t( - "myrepresentations:sign-in-to-raise-rep-label" - )}{" "} - - {t( - "myrepresentations:login-contact-email" - )} - -
-
<\/p>/g, "")
+ ? htmlStr.replace(
+ /
<\/p>|
<\/p>/g,
+ ""
+ )
: "";
return cleanStr;
diff --git a/components/pdftemplates/enforcement_pdf.js b/components/pdftemplates/enforcement_pdf.js
index ac5722a7..ba2579d2 100644
--- a/components/pdftemplates/enforcement_pdf.js
+++ b/components/pdftemplates/enforcement_pdf.js
@@ -104,7 +104,10 @@ export const EnforcementQuestionnaire_pdf = ({ docProps }) => {
function CleanHTML(htmlStr) {
let cleanStr =
typeof htmlStr === "string"
- ? htmlStr.replace(/
<\/p>/g, "")
+ ? htmlStr.replace(
+ /
<\/p>|
<\/p>/g,
+ ""
+ )
: "";
return cleanStr;
diff --git a/components/pdftemplates/finalComments_pdf.js b/components/pdftemplates/finalComments_pdf.js
index 556a4d9f..be300697 100644
--- a/components/pdftemplates/finalComments_pdf.js
+++ b/components/pdftemplates/finalComments_pdf.js
@@ -21,7 +21,7 @@ const getTrans = (locale, key) => {
let jsonObj = locale == "cy" ? transLookupCY : transLookupEN;
- console.log(locale, jsonObj[key]);
+ //console.log(locale, jsonObj[key]);
return jsonObj[key];
};
@@ -68,9 +68,8 @@ const styles = StyleSheet.create({
},
questionAnswerWide: {
color: "#757575",
- width: "95%",
+ width: "100%",
fontSize: 12,
- marginLeft: "5%",
border: 1,
borderColor: "#eee",
backgroundColor: "white",
@@ -125,7 +124,10 @@ export const finalComments_pdf = ({ docProps }) => {
function CleanHTML(htmlStr) {
let cleanStr =
typeof htmlStr === "string"
- ? htmlStr.replace(/
<\/p>/g, "")
+ ? htmlStr.replace(
+ /
<\/p>|
<\/p>/g,
+ ""
+ )
: "";
return cleanStr;
@@ -398,7 +400,10 @@ export const finalComments_pdf = ({ docProps }) => {
}
>
{p.name} -{" "}
- {bytesToSize(p.size)}{" "}
+ {bytesToSize(
+ p.size ||
+ p.contentLength
+ )}{" "}
{"\n"}
diff --git a/components/pdftemplates/lpaQuestionnaire_pdf.js b/components/pdftemplates/lpaQuestionnaire_pdf.js
index 16171483..0f8b44f5 100644
--- a/components/pdftemplates/lpaQuestionnaire_pdf.js
+++ b/components/pdftemplates/lpaQuestionnaire_pdf.js
@@ -61,6 +61,7 @@ const styles = StyleSheet.create({
border: 1,
borderColor: "#eee",
paddingLeft: 10,
+ paddingRight: 10,
backgroundColor: "white",
marginRight: 10,
},
@@ -86,9 +87,8 @@ const styles = StyleSheet.create({
},
questionAnswerWide: {
color: "#757575",
- width: "95%",
+ width: "100%",
fontSize: 12,
- marginLeft: "5%",
border: 1,
borderColor: "#eee",
backgroundColor: "white",
@@ -148,7 +148,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => {
function CleanHTML(htmlStr) {
let cleanStr =
typeof htmlStr === "string"
- ? htmlStr.replace(/
<\/p>/g, "")
+ ? htmlStr.replace(
+ /
<\/p>|
<\/p>/g,
+ ""
+ )
: "";
return cleanStr;
@@ -557,7 +560,6 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => {
wrap={false}
>
<\/p>/g, "")
+ ? htmlStr.replace(
+ /
<\/p>|
<\/p>/g,
+ ""
+ )
: "";
return cleanStr;
diff --git a/components/pdftemplates/statement_pdf.js b/components/pdftemplates/statement_pdf.js
index 6e8bcfbd..14ab7249 100644
--- a/components/pdftemplates/statement_pdf.js
+++ b/components/pdftemplates/statement_pdf.js
@@ -18,7 +18,7 @@ const getTrans = (locale, key) => {
let jsonObj = locale == "cy" ? transLookupCY : transLookupEN;
- console.log(locale, jsonObj[key]);
+ //console.log(locale, jsonObj[key]);
return jsonObj[key];
};
@@ -65,9 +65,8 @@ const styles = StyleSheet.create({
},
questionAnswerWide: {
color: "#757575",
- width: "95%",
+ width: "100%",
fontSize: 12,
- marginLeft: "5%",
border: 1,
borderColor: "#eee",
backgroundColor: "white",
@@ -97,7 +96,7 @@ const styles = StyleSheet.create({
});
export const statement_pdf = ({ docProps }) => {
- console.log("----", docProps);
+ //console.log("----", docProps);
function formatDates(dateObj) {
var dateObj = new Date(dateObj);
var dd = String(dateObj.getDate()).padStart(2, "0");
@@ -122,7 +121,10 @@ export const statement_pdf = ({ docProps }) => {
function CleanHTML(htmlStr) {
let cleanStr =
typeof htmlStr === "string"
- ? htmlStr.replace(/
<\/p>/g, "")
+ ? htmlStr.replace(
+ /
<\/p>|
<\/p>/g,
+ ""
+ )
: "";
return cleanStr;
@@ -395,7 +397,10 @@ export const statement_pdf = ({ docProps }) => {
}
>
{p.name} -{" "}
- {bytesToSize(p.size)}{" "}
+ {bytesToSize(
+ p.size ||
+ p.contentLength
+ )}{" "}
{"\n"}
<\/p>/g, "")
+ ? htmlStr.replace(
+ /
<\/p>|
<\/p>/g,
+ ""
+ )
: "";
return cleanStr;
diff --git a/pages/_document.js b/pages/_document.js
index 00c858b9..71b93947 100644
--- a/pages/_document.js
+++ b/pages/_document.js
@@ -42,7 +42,7 @@ class MyDocument extends Document {
csp += `form-action 'self' ` + process.env.NEXTAUTH_URL + ` ;`;
csp += `object-src 'self' data:;`;
csp += `default-src 'self' https://www.google-analytics.com;`;
- csp += `connect-src 'self' http://127.0.0.1 https://maps.googleapis.com https://ukwest-0.in.applicationinsights.azure.com https://js.monitor.azure.com https://region1.google-analytics.com;`;
+ csp += `connect-src 'self' http://127.0.0.1 https://maps.googleapis.com https://uksouth-1.in.applicationinsights.azure.com https://ukwest-0.in.applicationinsights.azure.com https://js.monitor.azure.com https://region1.google-analytics.com;`;
csp += `script-src 'self' 'unsafe-eval' 'unsafe-inline' https://maps.googleapis.com https://ukwest-0.in.applicationinsights.azure.com https://region1.google-analytics.com https://www.google-analytics.com/ https://tagmanager.google.com/ https://www.googletagmanager.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:;`;
diff --git a/pages/api/file/upload.js b/pages/api/file/upload.js
index 6bd36e0e..4219319a 100644
--- a/pages/api/file/upload.js
+++ b/pages/api/file/upload.js
@@ -35,20 +35,26 @@ ApiProxy.post(async (req, res) => {
repOrAppeal
? createRepBlob(appealData, containerID, casefolderID).then((data) => {
- Object.keys(req.files).length > 0 &&
- uploadFile(req.files, containerID, casefolderID).then(
- (data) => {
- return res.status(200).json({ data });
- }
- );
+ // Object.keys(req.files).length > 0 &&
+ // uploadFile(req.files, containerID, casefolderID).then(
+ // (data) => {
+ // return res.status(200).json({ data });
+ // }
+ // );
+ console.log("================================\nRepfile updated");
+ return res.status(200).json({ data });
})
: createBlob(appealData, containerID, casefolderID).then((data) => {
- Object.keys(req.files).length > 0 &&
- uploadFile(req.files, containerID, casefolderID).then(
- (data) => {
- return res.status(200).json({ data });
- }
- );
+ // Object.keys(req.files).length > 0 &&
+ // uploadFile(req.files, containerID, casefolderID).then(
+ // (data) => {
+ // return res.status(200).json({ data });
+ // }
+ // );
+ console.log(
+ "================================\nAppeal file updated"
+ );
+ return res.status(200).json({ data });
});
//});