multiple file upload issues capped at 210mb for now
This commit is contained in:
@@ -214,6 +214,9 @@ export default function BuildField(props) {
|
||||
props.props.props.props.accountDetails
|
||||
.containerID
|
||||
}
|
||||
uploadCount={props.uploadCount}
|
||||
setFileCount={props.props.setFileCount}
|
||||
setUploadCount={props.setUploadCount}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -16,6 +16,11 @@ export default function BuildRow(props) {
|
||||
sectionCount,
|
||||
onSubmit,
|
||||
mandatoryFieldsData,
|
||||
setUploadCount,
|
||||
uploadCount,
|
||||
setFileCount,
|
||||
completedUploadFilesCount,
|
||||
setCompletedUploadFilesCount,
|
||||
} = props;
|
||||
|
||||
const parser = new DOMParser();
|
||||
@@ -127,6 +132,9 @@ export default function BuildRow(props) {
|
||||
}
|
||||
mandatoryFieldsData={mandatoryFieldsData}
|
||||
documentTypeCode={documentTypeCode}
|
||||
setFileCount={setFileCount}
|
||||
setUploadCount={setUploadCount}
|
||||
uploadCount={uploadCount}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
setDocumentsList,
|
||||
setFilesForAppeal,
|
||||
setNewAppealProgress,
|
||||
setFileCount,
|
||||
} from "../../store/appealType/action";
|
||||
import { getFormCollectionByID, getProgressObj } from "../utils";
|
||||
import BuildRow from "./buildrow";
|
||||
@@ -21,8 +22,14 @@ import BuildProgress from "./buildprogress";
|
||||
let BuildSection = (props) => {
|
||||
const [currentSectionSelected, setCurrentSectionSelected] = useState(1);
|
||||
const [pickupWhereLeftOff, setPickupWhereLeftOff] = useState(true);
|
||||
|
||||
const [savingStatus, setSavingStatus] = useState(false);
|
||||
const [allFilesUploaded, setAllFilesuploaded] = useState(false);
|
||||
const [showCompletedUploadFiles, setShowCompletedUploadFiles] =
|
||||
useState(false);
|
||||
const [completedUploadFiles, setCompletedUploadFiles] = useState(false);
|
||||
const [uploadCount, setUploadCount] = useState(0);
|
||||
const [completedUploadFilesCount, setCompletedUploadFilesCount] =
|
||||
useState(0);
|
||||
|
||||
let { t } = useTranslation();
|
||||
|
||||
@@ -91,7 +98,7 @@ let BuildSection = (props) => {
|
||||
|
||||
const handleParam = (setValue) => (e) => setValue(e.target.value);
|
||||
|
||||
const uploadAppealFiles = (values) => {
|
||||
const uploadAppealFiles = async (values) => {
|
||||
// get filelists from values object
|
||||
let fileListObj = _.filter(values, function (v, key) {
|
||||
return _.includes(key, "pinswg_fileUpload");
|
||||
@@ -110,14 +117,14 @@ let BuildSection = (props) => {
|
||||
// _.includes(key, "pinswg_fileUpload") == true && delete dataObj[key];
|
||||
// }
|
||||
|
||||
uploadFiles(
|
||||
await uploadFiles(
|
||||
dataObj,
|
||||
fileListObj,
|
||||
props.props.accountDetails.containerID,
|
||||
props.props.appealType.caseReference.ticketnumber
|
||||
).then((data) => {
|
||||
//console.log("hello", data);
|
||||
|
||||
console.log("hello", data);
|
||||
setCompletedUploadFiles(true);
|
||||
return data;
|
||||
});
|
||||
};
|
||||
@@ -166,122 +173,143 @@ let BuildSection = (props) => {
|
||||
|
||||
setSavingStatus(useSaveStatus);
|
||||
|
||||
uploadAppealFiles(values);
|
||||
// console.log(
|
||||
// "\n////////////////////////\n appeal pdf payload",
|
||||
// values,
|
||||
// props.props.accountDetails.containerID,
|
||||
// props.appealType.caseReference.ticketnumber,
|
||||
// props.appealType,
|
||||
// "\n////////////////////////\n"
|
||||
// );
|
||||
setShowCompletedUploadFiles(true);
|
||||
|
||||
// let pdfObj = values;
|
||||
uploadAppealFiles(values)
|
||||
.then((data) => {
|
||||
// console.log(
|
||||
// "\n////////////////////////\n appeal pdf payload",
|
||||
// values,
|
||||
// props.props.accountDetails.containerID,
|
||||
// props.appealType.caseReference.ticketnumber,
|
||||
// props.appealType,
|
||||
// "\n////////////////////////\n"
|
||||
// );
|
||||
|
||||
// Object.assign(pdfObj, {
|
||||
// "containerID": props.props.accountDetails.containerID,
|
||||
// "casefolderID": props.appealType.caseReference.ticketnumber,
|
||||
// });
|
||||
// let pdfObj = values;
|
||||
|
||||
// generateAppealPDF(
|
||||
// pdfObj,
|
||||
// props.props.accountDetails.containerID,
|
||||
// props.appealType.caseReference.ticketnumber,
|
||||
// router.query.appealtypes,
|
||||
// props.appealType.fileList
|
||||
// ),
|
||||
// Object.assign(pdfObj, {
|
||||
// "containerID": props.props.accountDetails.containerID,
|
||||
// "casefolderID": props.appealType.caseReference.ticketnumber,
|
||||
// });
|
||||
|
||||
props.setNewAppealProgress(
|
||||
getProgressObj(formXML, titleList, mandatoryFieldsData, props)
|
||||
);
|
||||
// generateAppealPDF(
|
||||
// pdfObj,
|
||||
// props.props.accountDetails.containerID,
|
||||
// props.appealType.caseReference.ticketnumber,
|
||||
// router.query.appealtypes,
|
||||
// props.appealType.fileList
|
||||
// ),
|
||||
|
||||
let appTypeCollection = getFormCollectionByID(
|
||||
props.appealType.appealTypeID
|
||||
);
|
||||
let updateBindAppealTypeToIncident =
|
||||
appTypeCollection.NavigationProperty;
|
||||
props.setNewAppealProgress(
|
||||
getProgressObj(
|
||||
formXML,
|
||||
titleList,
|
||||
mandatoryFieldsData,
|
||||
props
|
||||
)
|
||||
);
|
||||
|
||||
Object.assign(updateBody, {
|
||||
"pinswg_appealcasetype": props.appealType.appealTypeID,
|
||||
"pinswg_Appellant@odata.bind":
|
||||
"/contacts(" + props.props.accountDetails.loggedinUserId + ")",
|
||||
"pinswg_name": props.appealType.caseReference.ticketnumber,
|
||||
[updateBindAppealTypeToIncident + "@odata.bind"]:
|
||||
"/incidents(" + incidentId + ")",
|
||||
});
|
||||
let appTypeCollection = getFormCollectionByID(
|
||||
props.appealType.appealTypeID
|
||||
);
|
||||
let updateBindAppealTypeToIncident =
|
||||
appTypeCollection.NavigationProperty;
|
||||
|
||||
updateBody = JSON.stringify(updateBody);
|
||||
updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
|
||||
updateBody = updateBody.replace(/:"No"/gm, `:false`);
|
||||
updateBody = JSON.parse(updateBody);
|
||||
Object.assign(updateBody, {
|
||||
"pinswg_appealcasetype": props.appealType.appealTypeID,
|
||||
"pinswg_Appellant@odata.bind":
|
||||
"/contacts(" +
|
||||
props.props.accountDetails.loggedinUserId +
|
||||
")",
|
||||
"pinswg_name": props.appealType.caseReference.ticketnumber,
|
||||
[updateBindAppealTypeToIncident + "@odata.bind"]:
|
||||
"/incidents(" + incidentId + ")",
|
||||
});
|
||||
|
||||
Object.keys(updateBody).forEach((key) => {
|
||||
if (updateBody[key] === null) {
|
||||
delete updateBody[key];
|
||||
}
|
||||
if (key.indexOf("_") == 0) {
|
||||
delete updateBody[key];
|
||||
}
|
||||
});
|
||||
updateBody = JSON.stringify(updateBody);
|
||||
updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
|
||||
updateBody = updateBody.replace(/:"No"/gm, `:false`);
|
||||
updateBody = JSON.parse(updateBody);
|
||||
|
||||
//console.log(updateBody);
|
||||
Object.keys(updateBody).forEach((key) => {
|
||||
if (updateBody[key] === null) {
|
||||
delete updateBody[key];
|
||||
}
|
||||
if (key.indexOf("_") == 0) {
|
||||
delete updateBody[key];
|
||||
}
|
||||
});
|
||||
|
||||
let updateFormCollection = appTypeCollection.LogicalCollectionName;
|
||||
let primaryAttribute = appTypeCollection.PrimaryIdAttribute;
|
||||
//console.log(updateBody);
|
||||
|
||||
const reference = "PEDW-PARTIAL";
|
||||
const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75";
|
||||
const templateIdCY = "f3c4a56b-bfb8-4d39-97dd-888df3062b0a";
|
||||
const emailAddress = props.props.accountDetails.loggedinUserEmail;
|
||||
const personalisation = {
|
||||
"caseReference": props.appealType.caseReference.ticketnumber,
|
||||
"emailAddress": props.props.accountDetails.loggedinUserEmail,
|
||||
"returnLink":
|
||||
props.props.url +
|
||||
(router.locale != "en" ? "/cy/fymhorth/" : "/myportal/") +
|
||||
appTypeCollection.UrlName +
|
||||
"?lpa=" +
|
||||
props.appealType.appealLPA +
|
||||
"&apt=" +
|
||||
appTypeCollection.appealTypeID +
|
||||
"&casereference=" +
|
||||
props.appealType.caseReference.ticketnumber +
|
||||
"&inid=" +
|
||||
props.appealType.caseReference.incidentid,
|
||||
"linkExpiry": 10 * 60,
|
||||
};
|
||||
let updateFormCollection =
|
||||
appTypeCollection.LogicalCollectionName;
|
||||
let primaryAttribute = appTypeCollection.PrimaryIdAttribute;
|
||||
|
||||
// console.log(
|
||||
// "/////////////////////////////////",
|
||||
// "returnLink:",
|
||||
// props.props.url +
|
||||
// (router.locale != "en" ? "/cy/fymhorth/" : "/myportal/") +
|
||||
// appTypeCollection.UrlName +
|
||||
// "?lpa=" +
|
||||
// props.appealType.appealLPA +
|
||||
// "&apt=" +
|
||||
// appTypeCollection.appealTypeID +
|
||||
// "&casereference=" +
|
||||
// props.appealType.caseReference.ticketnumber +
|
||||
// "&inid=" +
|
||||
// props.appealType.caseReference.incidentid,
|
||||
// "/////////////////////////////////"
|
||||
// );
|
||||
const reference = "PEDW-PARTIAL";
|
||||
const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75";
|
||||
const templateIdCY = "f3c4a56b-bfb8-4d39-97dd-888df3062b0a";
|
||||
const emailAddress =
|
||||
props.props.accountDetails.loggedinUserEmail;
|
||||
const personalisation = {
|
||||
"caseReference":
|
||||
props.appealType.caseReference.ticketnumber,
|
||||
"emailAddress":
|
||||
props.props.accountDetails.loggedinUserEmail,
|
||||
"returnLink":
|
||||
props.props.url +
|
||||
(router.locale != "en"
|
||||
? "/cy/fymhorth/"
|
||||
: "/myportal/") +
|
||||
appTypeCollection.UrlName +
|
||||
"?lpa=" +
|
||||
props.appealType.appealLPA +
|
||||
"&apt=" +
|
||||
appTypeCollection.appealTypeID +
|
||||
"&casereference=" +
|
||||
props.appealType.caseReference.ticketnumber +
|
||||
"&inid=" +
|
||||
props.appealType.caseReference.incidentid,
|
||||
"linkExpiry": 10 * 60,
|
||||
};
|
||||
|
||||
sendSavedEmail == true &&
|
||||
sendEmail(
|
||||
router.locale != "en" ? templateIdCY : templateId,
|
||||
emailAddress,
|
||||
personalisation,
|
||||
reference
|
||||
);
|
||||
// console.log(
|
||||
// "/////////////////////////////////",
|
||||
// "returnLink:",
|
||||
// props.props.url +
|
||||
// (router.locale != "en" ? "/cy/fymhorth/" : "/myportal/") +
|
||||
// appTypeCollection.UrlName +
|
||||
// "?lpa=" +
|
||||
// props.appealType.appealLPA +
|
||||
// "&apt=" +
|
||||
// appTypeCollection.appealTypeID +
|
||||
// "&casereference=" +
|
||||
// props.appealType.caseReference.ticketnumber +
|
||||
// "&inid=" +
|
||||
// props.appealType.caseReference.incidentid,
|
||||
// "/////////////////////////////////"
|
||||
// );
|
||||
})
|
||||
.then(() => {
|
||||
sendSavedEmail == true &&
|
||||
sendEmail(
|
||||
router.locale != "en" ? templateIdCY : templateId,
|
||||
emailAddress,
|
||||
personalisation,
|
||||
reference
|
||||
);
|
||||
|
||||
useSaveStatus &&
|
||||
router.replace(
|
||||
router.locale != "en"
|
||||
? "/" + router.locale + "/myportal"
|
||||
: "/myportal"
|
||||
);
|
||||
useSaveStatus &&
|
||||
router.replace(
|
||||
router.locale != "en"
|
||||
? "/" + router.locale + "/myportal"
|
||||
: "/myportal"
|
||||
);
|
||||
})
|
||||
.then(() => {
|
||||
setCompletedUploadFiles(true);
|
||||
});
|
||||
};
|
||||
|
||||
const onHandleSubmit = (values) => {
|
||||
@@ -335,9 +363,11 @@ let BuildSection = (props) => {
|
||||
|
||||
delete valuesObj["_pinswg_appellant_value"];
|
||||
//console.log("has errors:", props.invalid);
|
||||
props.invalid == false && updateCaseProgress(valuesObj, false, false);
|
||||
|
||||
setCurrentSection(currentSection + 1);
|
||||
props.invalid == false &&
|
||||
updateCaseProgress(valuesObj, false, false).then((data) => {
|
||||
console.log(data);
|
||||
setCurrentSection(currentSection + 1);
|
||||
});
|
||||
};
|
||||
|
||||
const [hasErrors, setHasErrors] = useState("");
|
||||
@@ -406,6 +436,16 @@ let BuildSection = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const hasUploadFiles = () => {
|
||||
const formArr = props.props.form["appealForm"].values;
|
||||
const prefix = "pinswg_fileUpload";
|
||||
const hasFiles = Object.keys(formArr).some((key) =>
|
||||
key.startsWith(prefix)
|
||||
);
|
||||
|
||||
return hasFiles;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-two-thirds wgForm ">
|
||||
@@ -429,6 +469,15 @@ let BuildSection = (props) => {
|
||||
onSubmit={onSubmit}
|
||||
mandatoryFieldsData={mandatoryFieldsData}
|
||||
props={props}
|
||||
allFilesUploaded={allFilesUploaded}
|
||||
setAllFilesuploaded={setAllFilesuploaded}
|
||||
setFileCount={setFileCount}
|
||||
setUploadCount={setUploadCount}
|
||||
uploadCount={uploadCount}
|
||||
completedUploadFilesCount={completedUploadFilesCount}
|
||||
setCompletedUploadFilesCount={
|
||||
setCompletedUploadFilesCount
|
||||
}
|
||||
/>
|
||||
|
||||
<div className="govuk-button-group">
|
||||
@@ -523,13 +572,18 @@ let BuildSection = (props) => {
|
||||
)}
|
||||
{props.sectionCount == currentSection ? (
|
||||
<>
|
||||
<div>
|
||||
{showCompletedUploadFiles
|
||||
? "UPlodeding, pleas ewait "
|
||||
: ""}
|
||||
</div>
|
||||
<button
|
||||
disabled={!isProgressComplete(progObj)}
|
||||
type="submit"
|
||||
className="govuk-button"
|
||||
data-module="govuk-button"
|
||||
>
|
||||
{t("common:submit-button")}
|
||||
{t("common:submit-button")}{" "}
|
||||
</button>
|
||||
{savingStatus ? (
|
||||
<span className=" progress-save-active">
|
||||
@@ -655,6 +709,9 @@ const mapDispatchToProps = (dispatch) => {
|
||||
setNewAppealProgress: (progressObj) => {
|
||||
dispatch(setNewAppealProgress(progressObj));
|
||||
},
|
||||
setFileCount: (fileCount) => {
|
||||
dispatch(setFileCount(fileCount));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user