uploading files to reps
This commit is contained in:
@@ -41,7 +41,7 @@ const RepCompleteSubmit = (props) => {
|
||||
|
||||
const repFormData = formObj.representationForm.values;
|
||||
|
||||
// const repDate = new Date();
|
||||
//const repDate = new Date();
|
||||
|
||||
// let day = repDate.getDate();
|
||||
// let month = repDate.getMonth() + 1;
|
||||
@@ -135,6 +135,48 @@ const RepCompleteSubmit = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
let buildAppealFilesArray = [];
|
||||
|
||||
let filesUploadObj =
|
||||
formObj.representationForm.values.representationDocuments;
|
||||
|
||||
for (let key in filesUploadObj) {
|
||||
typeof filesUploadObj[key].name != "undefined" &&
|
||||
buildAppealFilesArray.push({
|
||||
"name": filesUploadObj[key].name,
|
||||
"size": filesUploadObj[key].size,
|
||||
});
|
||||
}
|
||||
|
||||
console.log(
|
||||
buildAppealFilesArray,
|
||||
formObj.representationForm.values.filesList
|
||||
);
|
||||
|
||||
buildAppealFilesArray = formObj.representationForm.values.hasOwnProperty(
|
||||
"filesList"
|
||||
)
|
||||
? buildAppealFilesArray.concat(
|
||||
formObj.representationForm.values.filesList
|
||||
)
|
||||
: buildAppealFilesArray;
|
||||
|
||||
console.log(buildAppealFilesArray);
|
||||
|
||||
// const arrUniq = [
|
||||
// ...new Map(buildAppealFilesArray.map((v) => [v.name, v])).values(),
|
||||
// ];
|
||||
|
||||
const arrUniq = buildAppealFilesArray.filter(
|
||||
(obj1, i, arr) => arr.findIndex((obj2) => obj2.name === obj1.name) === i
|
||||
);
|
||||
|
||||
console.log(arrUniq);
|
||||
|
||||
Object.assign(formObj.representationForm.values, {
|
||||
"filesList": arrUniq,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
{currentView.representationSubmitConfirmation == true ? (
|
||||
@@ -303,10 +345,7 @@ const RepCompleteSubmit = (props) => {
|
||||
</dt>
|
||||
|
||||
<dd className="govuk-summary-list__value">
|
||||
{formObj.representationForm.values.hasOwnProperty(
|
||||
"filesList"
|
||||
) &&
|
||||
formObj.representationForm.values
|
||||
{formObj.representationForm.values
|
||||
.filesList.length > 0
|
||||
? formObj.representationForm.values.filesList.map(
|
||||
(blob, i) => (
|
||||
|
||||
Reference in New Issue
Block a user