update pdf templates with attched docs
This commit is contained in:
@@ -403,6 +403,22 @@ let MakeRepresentation = (props) => {
|
||||
|
||||
const onHandleSubmit = (values) => {
|
||||
console.log("form values - ", JSON.stringify(values));
|
||||
|
||||
const buildFileArray = [];
|
||||
|
||||
console.log("attached docs: - ", buildFileArray);
|
||||
|
||||
let setCaseDetailsObj = props.props.searchResultsObj.searchDetailsObj;
|
||||
|
||||
var detailsObj = {};
|
||||
|
||||
detailsObj = jsonpath.query(
|
||||
setCaseDetailsObj,
|
||||
'$..[?(@.pinswg_name=="' + caseReference + '")]'
|
||||
);
|
||||
|
||||
detailsObj = detailsObj[0];
|
||||
|
||||
Object.assign(values, {
|
||||
"containerID": props.props.accountDetails.containerID,
|
||||
"appealType": props.props.currentView.caseReference.appealType,
|
||||
@@ -414,8 +430,16 @@ let MakeRepresentation = (props) => {
|
||||
"lastname": props.props.accountDetails.accountDetails.lastname,
|
||||
"emailAddress":
|
||||
props.props.accountDetails.accountDetails.emailaddress1,
|
||||
"siteAddress":
|
||||
detailsObj.pinswg_siteaddressline1 +
|
||||
" " +
|
||||
detailsObj.pinswg_siteaddressline2 +
|
||||
" " +
|
||||
detailsObj.pinswg_siteaddresstown +
|
||||
" " +
|
||||
detailsObj.pinswg_siteaddresspostcode,
|
||||
});
|
||||
|
||||
console.log(values);
|
||||
currentView.representationSubmit != true
|
||||
? _.isEmpty(currentView.representationCapacity)
|
||||
? isLPA
|
||||
@@ -431,6 +455,10 @@ let MakeRepresentation = (props) => {
|
||||
console.log("has errors:", props.invalid),
|
||||
props.invalid == false &&
|
||||
updateRepresentation(values, false, false),
|
||||
values.representationDocuments.map((Blob) =>
|
||||
buildFileArray.push({ "name": Blob.name, "size": Blob.size })
|
||||
),
|
||||
Object.assign(values, { "filesList": buildFileArray }),
|
||||
generateRepPDF(
|
||||
values,
|
||||
props.props.accountDetails.containerID,
|
||||
|
||||
@@ -30,6 +30,56 @@ const RepCompleteSubmit = (props) => {
|
||||
|
||||
const repFormData = formObj.representationForm.values;
|
||||
|
||||
const getThumbnailIconByExtension = (blobName) => {
|
||||
let fileType = blobName.slice(blobName.lastIndexOf(".") + 1);
|
||||
|
||||
switch (fileType) {
|
||||
case "html":
|
||||
return "/assets/images/documenttypes/html.png";
|
||||
break;
|
||||
case "txt":
|
||||
return "/assets/images/documenttypes/txt.png";
|
||||
break;
|
||||
case "doc":
|
||||
return "/assets/images/documenttypes/doc.png";
|
||||
break;
|
||||
case "pdf":
|
||||
return "/assets/images/documenttypes/pdf.png";
|
||||
break;
|
||||
case "docx":
|
||||
return "/assets/images/documenttypes/docx.png";
|
||||
break;
|
||||
case "csv":
|
||||
return "/assets/images/documenttypes/csv.png";
|
||||
break;
|
||||
case "xlsx":
|
||||
return "/assets/images/documenttypes/xlsx.png";
|
||||
break;
|
||||
|
||||
case "zip":
|
||||
return "/assets/images/documenttypes/zip.png";
|
||||
break;
|
||||
case "jpeg":
|
||||
case "jpg":
|
||||
return "/assets/images/documenttypes/jpg.png";
|
||||
case "png":
|
||||
return "/assets/images/documenttypes/png.png";
|
||||
break;
|
||||
default:
|
||||
return "/assets/images/documenttypes/txt.png";
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
function bytesToSize(bytes) {
|
||||
var sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
||||
if (bytes == 0) return "0 Byte";
|
||||
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
|
||||
return Math.round(bytes / Math.pow(1024, i), 2) + " " + sizes[i];
|
||||
}
|
||||
|
||||
console.log("///////// formObj:", formObj);
|
||||
|
||||
return (
|
||||
<>
|
||||
{currentView.representationSubmitConfirmation == true ? (
|
||||
@@ -190,7 +240,37 @@ const RepCompleteSubmit = (props) => {
|
||||
</dt>
|
||||
|
||||
<dd className="govuk-summary-list__value">
|
||||
files
|
||||
{formObj.representationForm.values
|
||||
.representationDocuments.length > 0
|
||||
? formObj.representationForm.values.representationDocuments.map(
|
||||
(blob, i) => (
|
||||
<div
|
||||
key={
|
||||
blob.name +
|
||||
"_" +
|
||||
i
|
||||
}
|
||||
className="govuk-!-margin-bottom-5 fileThumb "
|
||||
>
|
||||
<img
|
||||
src={getThumbnailIconByExtension(
|
||||
blob.name
|
||||
)}
|
||||
alt={blob.name}
|
||||
width="50"
|
||||
/>
|
||||
|
||||
<span className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5">
|
||||
{blob.name} (
|
||||
{bytesToSize(
|
||||
blob.size
|
||||
)}
|
||||
)
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
)
|
||||
: ""}{" "}
|
||||
</dd>
|
||||
|
||||
<dd className="govuk-summary-list__actions">
|
||||
|
||||
Reference in New Issue
Block a user