From 665c4bbba51c861664d7d24124cb16f6b7f55107 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 13 Jan 2025 18:21:40 +0000 Subject: [PATCH] uat defect 124, rep defect 11, questionnaire defect 26 --- actions/index.js | 12 +-- components/case/representation/index.js | 93 +++++++++++-------- .../representation/representationAgent.js | 34 +++---- .../representation/representationAppellant.js | 29 +++--- .../representation/representationElements.js | 18 +++- .../representationInterestedPartyPerson.js | 34 +++---- .../case/representation/representationLPA.js | 53 +++++++---- ...resentationLPAQuestionnaire_enforcement.js | 25 ++--- 8 files changed, 173 insertions(+), 125 deletions(-) diff --git a/actions/index.js b/actions/index.js index 4adf8941..335b7064 100644 --- a/actions/index.js +++ b/actions/index.js @@ -1566,12 +1566,12 @@ export const uploadRepFiles = async ( // files.forEach((file) => formData.append("files", file)); - for (let i = 0; i < files.length; i++) { - for (let j = 0; j < files[i].length; j++) { - //console.log("upload rep files:", files[i][j].name); - formData.append(files[i][j].name, files[i][j]); - } - } + // for (let i = 0; i < files.length; i++) { + // for (let j = 0; j < files[i].length; j++) { + // //console.log("upload rep files:", files[i][j].name); + // formData.append(files[i][j].name, files[i][j]); + // } + // } //console.log(formData); diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 3b045eba..0071b180 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -129,6 +129,7 @@ let MakeRepresentation = (props) => { repCap = "LO"; break; case "lpa": + case "LPA": repCap = "LPA"; break; @@ -204,7 +205,7 @@ let MakeRepresentation = (props) => { return values; }; - isLPA && setRepresentationCapacity("lpa"); + isLPA && setRepresentationCapacity("LPA"); currentType == "searchResultsObj" ? (casesObj = jsonpath( @@ -248,8 +249,27 @@ let MakeRepresentation = (props) => { ? props.props.watchedCases.watchedCasesDetails : props.props.searchResultsObj.searchDetailsObj; + let setCaseResultsObj = router.query.hasOwnProperty("state") + ? router.query.state == "edit" + ? props.props.myRepresentations.myRepresentations + : props.props.searchResultsObj.searchResultsObj + : props.currentType == "watchedCases" + ? props.props.watchedCases.watchedCasesDetails + : props.props.searchResultsObj.searchResultsObj; + var detailsObj = {}; + var resultsObj = {}; + + resultsObj = jsonpath( + '$..[?(@.ticketnumber=="' + + currentView.caseReference.currentReference + + '")]', + setCaseResultsObj + ); + + resultsObj = resultsObj[0]; + detailsObj = jsonpath( '$..[?(@.pinswg_name=="' + currentView.caseReference.currentReference + @@ -396,7 +416,7 @@ let MakeRepresentation = (props) => { ) ) { return ( - //setRepresentationCapacity("lpa"), + //setRepresentationCapacity("LPA"), { ); break; case "lpa": + case "LPA": //setRepresentationCapacity("appellant"); - //setRepresentationCapacity("lpa"); + //setRepresentationCapacity("LPA"); // useEffect(() => { - // setRepresentationCapacity("lpa"); + // setRepresentationCapacity("LPA"); // }, []); // console.log(currentView.caseReference.appealType); @@ -761,6 +782,7 @@ let MakeRepresentation = (props) => { "pinswg_siteaddressline2": detailsObj.pinswg_siteaddressline2, "pinswg_siteaddresstown": detailsObj.pinswg_siteaddresstown, "pinswg_siteaddresspostcode": detailsObj.pinswg_siteaddresspostcode, + "pinswg_lpareference": resultsObj.pinswg_lpareference, "_pinswg_appellant_value": detailsObj["_pinswg_appellant_value"], "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue": detailsObj[ @@ -777,7 +799,7 @@ let MakeRepresentation = (props) => { ? props.props.currentView.representationCapacity : values.representationCapacity : isLPA - ? "lpa" + ? "LPA" : values.representationCapacity, "locale": router.locale, }); @@ -840,23 +862,15 @@ let MakeRepresentation = (props) => { : "/myportal" )) : useSaveStatus - ? (values.hasOwnProperty("representationDocuments") && - (values.representationDocuments.map((Blob) => - buildFileArray.push({ - "name": Blob.name, - "size": Blob.size, - }) - ), - (newbuildArr = buildFileArray.concat(values.filesList)), - console.log(buildFileArray, newbuildArr), - Object.assign(values, { - "filesList": newbuildArr, - })), - generateRepPDF( - values, - props.props.accountDetails.containerID, - currentView.caseReference.currentReference - ), + ? (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" @@ -874,25 +888,26 @@ let MakeRepresentation = (props) => { // Object.assign(values, { // "filesList": buildFileArray, // })), - - uploadRepresentationFiles(values), - generateRepPDF( - values, - props.props.accountDetails.containerID, - currentView.caseReference.currentReference - ); + console.log("updated"); + uploadRepresentationFiles(values); + // generateRepPDF( + // values, + // props.props.accountDetails.containerID, + // currentView.caseReference.currentReference + // ); }; const onHandleSubmit = (values) => { window.scrollTo({ top: 0, behavior: "smooth" }); values = setRepFileName(values); - !values.hasOwnProperty("pinswg_lpareference") && - Object.assign(values, { - "pinswg_lpareference": - searchResultsObj.searchResultsObj.value[0] - .pinswg_lpareference, - }); + // 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)); @@ -973,6 +988,7 @@ let MakeRepresentation = (props) => { "pinswg_siteaddresstown": detailsObj.pinswg_siteaddresstown, "pinswg_siteaddresspostcode": detailsObj.pinswg_siteaddresspostcode, + "pinswg_lpareference": resultsObj.pinswg_lpareference, "_pinswg_appellant_value": detailsObj["_pinswg_appellant_value"], "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue": @@ -990,7 +1006,7 @@ let MakeRepresentation = (props) => { ? props.props.currentView.representationCapacity : values.representationCapacity : isLPA - ? "lpa" + ? "LPA" : values.representationCapacity, "locale": router.locale, })); @@ -998,7 +1014,7 @@ let MakeRepresentation = (props) => { if (currentView.representationSubmit != true) { if (_.isEmpty(currentView.representationCapacity)) { if (isLPA) { - setRepresentationCapacity("lpa"); + setRepresentationCapacity("LPA"); } else { setRepresentationCapacity( values.representationCapacity @@ -1055,6 +1071,7 @@ let MakeRepresentation = (props) => { currentView.caseReference.currentReference ); uploadRepresentationFiles(values); + setRepresentationSubmit(true); setRepresentationSubmitConfirmation(true); } else { console.log("nit updated"); @@ -1064,7 +1081,7 @@ let MakeRepresentation = (props) => { // currentView.representationSubmit != true // ? _.isEmpty(currentView.representationCapacity) // ? isLPA - // ? setRepresentationCapacity("lpa") + // ? setRepresentationCapacity("LPA") // : setRepresentationCapacity( // values.representationCapacity // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") diff --git a/components/case/representation/representationAgent.js b/components/case/representation/representationAgent.js index a9ed801d..f29115e2 100644 --- a/components/case/representation/representationAgent.js +++ b/components/case/representation/representationAgent.js @@ -199,22 +199,24 @@ const RepAgent = (props) => { } hint={"sdsd"} fileList={ - props.currentView.caseReference.hasOwnProperty( - "repDetails" - ) - ? props.currentView.caseReference.repDetails.hasOwnProperty( - "filesList" - ) && - props.currentView - .caseReference - .repDetails.filesList - .length > 0 - ? props.currentView - .caseReference - .repDetails - .filesList - : [] - : [] + props.currentView.fileList + + // props.currentView.caseReference.hasOwnProperty( + // "repDetails" + // ) + // ? props.currentView.caseReference.repDetails.hasOwnProperty( + // "filesList" + // ) && + // props.currentView + // .caseReference + // .repDetails.filesList + // .length > 0 + // ? props.currentView + // .caseReference + // .repDetails + // .filesList + // : [] + // : [] } setFilesForRepresentations={ setFilesForRepresentations diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js index 7abea2e1..64ccd627 100644 --- a/components/case/representation/representationAppellant.js +++ b/components/case/representation/representationAppellant.js @@ -191,20 +191,21 @@ const RepAppellant = (props) => { ticketnumber={props.props.caseReference} hint={"sdsd"} fileList={ - props.currentView.caseReference.hasOwnProperty( - "repDetails" - ) - ? props.currentView.caseReference.repDetails.hasOwnProperty( - "filesList" - ) && - props.currentView - .caseReference.repDetails - .filesList.length > 0 - ? props.currentView - .caseReference - .repDetails.filesList - : [] - : [] + props.currentView.fileList + // props.currentView.caseReference.hasOwnProperty( + // "repDetails" + // ) + // ? props.currentView.caseReference.repDetails.hasOwnProperty( + // "filesList" + // ) && + // props.currentView + // .caseReference.repDetails + // .filesList.length > 0 + // ? props.currentView + // .caseReference + // .repDetails.filesList + // : [] + // : [] } setFilesForRepresentations={ setFilesForRepresentations diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js index db6221c8..6f51a3c2 100644 --- a/components/case/representation/representationElements.js +++ b/components/case/representation/representationElements.js @@ -7,7 +7,7 @@ import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; import Dropzone from "react-dropzone"; import "react-quill-new/dist/quill.snow.css"; -import { Field } from "redux-form"; +import { Field, change } from "redux-form"; import { uploadSingleFile, deleteBlob, @@ -17,6 +17,7 @@ import { } from "../../../actions"; const ReactQuill = dynamic(() => import("react-quill-new"), { ssr: false }); +import { useDispatch } from "react-redux"; // Import the useDispatch hook import { addDays, @@ -867,6 +868,8 @@ const rejectStyle = { export const RenderFileUpload = (field) => { const files = field.input.value; + const dispatch = useDispatch(); // Get dispatch using useDispatch hook + let { t } = useTranslation(); const style = useMemo( @@ -929,9 +932,9 @@ export const RenderFileUpload = (field) => { const filelistObj = field.fileList || {}; - //let blobList = filelistObj; + let blobList = filelistObj; - let blobList = field.props.currentView.fileList; + //let blobList = field.props.currentView.fileList; function removeNullObjects(arr) { if (arr.length === 0) { @@ -1063,6 +1066,7 @@ export const RenderFileUpload = (field) => { [".xlsx"], }} onDrop={(filesToUpload, e) => { + setCompletedUploadFiles(false); const renamedAcceptedFiles = filesToUpload.map( (file) => new File( @@ -1150,9 +1154,13 @@ export const RenderFileUpload = (field) => { )) ).then((data) => { data = data.value || {}; - field.input.value == null; + field.input.value = ""; field.setFilesForRepresentations(data[0]); setCompletedUploadFiles(true); + + dispatch( + change("representationForm", field.name, null) + ); // Set the field value to null }); }); }} @@ -1283,7 +1291,7 @@ export const RenderFileUpload = (field) => { field.ticketnumber + "/" + field.filenamePrefix.representationForm - .values.repfile_name + ?.values?.repfile_name ) + "&blobname=" + blob.name + diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index 2ceee4f9..3649b418 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -186,22 +186,24 @@ const RepInterestedPartyPerson = (props) => { } hint={"sdsd"} fileList={ - props.currentView.caseReference.hasOwnProperty( - "repDetails" - ) - ? props.currentView.caseReference.repDetails.hasOwnProperty( - "filesList" - ) && - props.currentView - .caseReference - .repDetails.filesList - .length > 0 - ? props.currentView - .caseReference - .repDetails - .filesList - : [] - : [] + props.currentView.fileList + + // props.currentView.caseReference.hasOwnProperty( + // "repDetails" + // ) + // ? props.currentView.caseReference.repDetails.hasOwnProperty( + // "filesList" + // ) && + // props.currentView + // .caseReference + // .repDetails.filesList + // .length > 0 + // ? props.currentView + // .caseReference + // .repDetails + // .filesList + // : [] + // : [] } setFilesForRepresentations={ setFilesForRepresentations diff --git a/components/case/representation/representationLPA.js b/components/case/representation/representationLPA.js index 9b54a752..ed266276 100644 --- a/components/case/representation/representationLPA.js +++ b/components/case/representation/representationLPA.js @@ -352,23 +352,24 @@ let RepLPA = (props) => { } hint={"sdsd"} fileList={ - (props.formObj.hasOwnProperty( - "representationForm" - ) && - props.formObj[ - "representationForm" - ].hasOwnProperty( - "values" - ) && - props.formObj[ - "representationForm" - ].values.hasOwnProperty( - "filesList" - ) && - props.props.props.form[ - "representationForm" - ].values.filesList) || - [] + props.currentView.fileList + // (props.formObj.hasOwnProperty( + // "representationForm" + // ) && + // props.formObj[ + // "representationForm" + // ].hasOwnProperty( + // "values" + // ) && + // props.formObj[ + // "representationForm" + // ].values.hasOwnProperty( + // "filesList" + // ) && + // props.props.props.form[ + // "representationForm" + // ].values.filesList) || + // [] } setFilesForRepresentations={ setFilesForRepresentations @@ -505,6 +506,22 @@ let RepLPA = (props) => { className="govuk-button" data-module="govuk-button" onClick={() => { + let valuesObj = + props.props.props.form[props.form] + .values || {}; + + console.log("valuesobj:", valuesObj); + + delete valuesObj[ + "_pinswg_appellant_value" + ]; + + console.log("on save:", valuesObj); + updateRepresentation( + valuesObj, + false, + false + ); setRepresentationSubmit(true); }} > @@ -604,7 +621,7 @@ const mapStateToProps = (state, props) => { ? state.currentView.caseReference.repDetails : state.currentView.caseReference, { - "representationCapacity": "lpa", + "representationCapacity": "LPA", "onBehalfOfLPA": props.props.props.accountDetails.accountDetails[ "pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue" diff --git a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js index 39d5d4e2..b8d4d1a1 100644 --- a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js +++ b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js @@ -1181,18 +1181,19 @@ let Enforcement_Questionnaire = (props) => { ticketnumber={props.props.props.caseReference} hint={"sdsd"} fileList={ - props.currentView.caseReference.hasOwnProperty( - "repDetails" - ) - ? props.currentView.caseReference.repDetails.hasOwnProperty( - "filesList" - ) && - props.currentView.caseReference.repDetails - .filesList.length > 0 - ? props.currentView.caseReference - .repDetails.filesList - : [] - : [] + props.currentView.fileList + // props.currentView.caseReference.hasOwnProperty( + // "repDetails" + // ) + // ? props.currentView.caseReference.repDetails.hasOwnProperty( + // "filesList" + // ) && + // props.currentView.caseReference.repDetails + // .filesList.length > 0 + // ? props.currentView.caseReference + // .repDetails.filesList + // : [] + // : [] } setFilesForRepresentations={ setFilesForRepresentations