diff --git a/components/case.js b/components/case.js index 19631bbe..ad065bbc 100644 --- a/components/case.js +++ b/components/case.js @@ -40,6 +40,7 @@ const Case = (props) => { docsOffline={props.props.docsOffline} documentDetailsObj={props.documentDetailsObj} showFilteredDocs={props.showFilteredDocs} + ticketnumber={props.ticketnumber} /> {showRepresentations == true && ( { resultsObj = jsonpath({ path: '$..[?(@ && @.ticketnumber=="' + - currentView.caseReference.currentReference + + currentView.caseReference.ticketnumber + '")]', json: setCaseResultsObj, eval: true, @@ -296,8 +296,8 @@ let MakeRepresentation = (props) => { }) : jsonpath({ path: - '$..[?(@ && @.pinswg_name =="' + - currentView.caseReference.currentReference + + '$..[?(@ && @.ticketnumber =="' + + currentView.caseReference.ticketnumber + '")]', json: setCaseDetailsObj, eval: true, @@ -767,6 +767,26 @@ let MakeRepresentation = (props) => { return blobList; }; + const buildAddressStr = (detailsObj) => { + const toTitleCase = (str) => + str.toLowerCase().replace(/\b\w/g, (char) => char.toUpperCase()); + + return [ + detailsObj?.pinswg_siteaddressline1 || + detailsObj?.pinswg_addressline1, + detailsObj?.pinswg_siteaddressline2 || + detailsObj?.pinswg_addressline2, + detailsObj?.pinswg_siteaddresstown || + detailsObj?.pinswg_addresstown, + detailsObj?.pinswg_siteaddresspostcode || + detailsObj?.pinswg_postcode, + detailsObj?.pinswg_siteaddresscounty || + detailsObj?.pinswg_addresscounty, + ] + .filter((v) => !!v && v.trim()) // remove empty/whitespace-only values + .map((v) => toTitleCase(v.trim())) // title-case each segment + .join(" "); + }; const updateRepresentation = async ( values, sendSavedEmail, @@ -807,14 +827,7 @@ let MakeRepresentation = (props) => { "lastname": props.props.accountDetails.accountDetails.lastname, "emailAddress": props.props.accountDetails.accountDetails.emailaddress1, - "siteAddress": - detailsObj.pinswg_siteaddressline1 + - (detailsObj.pinswg_siteaddressline2 != null - ? " " + detailsObj.pinswg_siteaddressline2 + " " - : " ") + - detailsObj.pinswg_siteaddresstown + - " " + - detailsObj.pinswg_siteaddresspostcode, + "siteAddress": buildAddressStr(detailsObj), "pinswg_siteaddressline1": detailsObj.pinswg_siteaddressline1, "pinswg_siteaddressline2": detailsObj.pinswg_siteaddressline2, "pinswg_siteaddresstown": detailsObj.pinswg_siteaddresstown, @@ -945,7 +958,10 @@ let MakeRepresentation = (props) => { var detailsObj = {}; detailsObj = jsonpath({ - path: '$..[?(@ && @.pinswg_name=="' + caseReference + '")]', + path: + '$..[?(@ && @.ticketnumber=="' + + currentView.caseReference.ticketnumber + + '")]', json: setCaseDetailsObj, eval: true, }); @@ -974,16 +990,19 @@ let MakeRepresentation = (props) => { props.props.currentView.caseReference.currentReference, "casereference": props.props.currentView.caseReference.currentReference, + "ticketnumber": + props.props.currentView.caseReference.ticketnumber, "pinswg_questionnaireduedate": - detailsObj.pinswg_questionnaireduedate, + detailsObj?.pinswg_questionnaireduedate, "pinswg_endofrepresentationperiod": - detailsObj.pinswg_endofrepresentationperiod, + detailsObj?.pinswg_endofrepresentationperiod, "pinswg_applicationacceptedasvalid": - detailsObj.pinswg_applicationacceptedasvalid, - "pinswg_statementduedate": detailsObj.pinswg_statementduedate, - "pinswg_statementsduedate": detailsObj.pinswg_statementsduedate, + detailsObj?.pinswg_applicationacceptedasvalid, + "pinswg_statementduedate": detailsObj?.pinswg_statementduedate, + "pinswg_statementsduedate": + detailsObj?.pinswg_statementsduedate, "pinswg_finalcommentsduedate": - detailsObj.pinswg_finalcommentsduedate, + detailsObj?.pinswg_finalcommentsduedate, "pinswg_name": props.props.currentView.caseReference.currentReference, "firstname": @@ -991,19 +1010,12 @@ let MakeRepresentation = (props) => { "lastname": props.props.accountDetails.accountDetails.lastname, "emailAddress": props.props.accountDetails.accountDetails.emailaddress1, - "siteAddress": - detailsObj.pinswg_siteaddressline1 + - (detailsObj.pinswg_siteaddressline2 != null - ? " " + detailsObj.pinswg_siteaddressline2 + " " - : " ") + - detailsObj.pinswg_siteaddresstown + - " " + - detailsObj.pinswg_siteaddresspostcode, - "pinswg_siteaddressline1": detailsObj.pinswg_siteaddressline1, - "pinswg_siteaddressline2": detailsObj.pinswg_siteaddressline2, - "pinswg_siteaddresstown": detailsObj.pinswg_siteaddresstown, + "siteAddress": buildAddressStr(detailsObj), + "pinswg_siteaddressline1": detailsObj?.pinswg_siteaddressline1, + "pinswg_siteaddressline2": detailsObj?.pinswg_siteaddressline2, + "pinswg_siteaddresstown": detailsObj?.pinswg_siteaddresstown, "pinswg_siteaddresspostcode": - detailsObj.pinswg_siteaddresspostcode, + detailsObj?.pinswg_siteaddresspostcode, "pinswg_lpareference": resultsObj?.pinswg_lpareference || "", "_pinswg_appellant_value": detailsObj["_pinswg_appellant_value"], @@ -1068,7 +1080,7 @@ let MakeRepresentation = (props) => { console.log("has errors:", props.invalid); Object.assign(values, { "locale": router.locale, - "repComplete": currentView.caseReference.currentReference, + "repComplete": currentView.caseReference.ticketnumber, }); props.invalid == false && updateRepresentation(values, false, false); @@ -1169,7 +1181,9 @@ let MakeRepresentation = (props) => { dataObj, [{}], values.containerID, - props.caseReference + "/" + dataObj.repfile_name + props.props.currentView.caseReference.ticketnumber + + "/" + + dataObj.repfile_name ).then((data) => { return data; }); diff --git a/components/case/representation/representationAgent.js b/components/case/representation/representationAgent.js index 6e13b87e..46a43952 100644 --- a/components/case/representation/representationAgent.js +++ b/components/case/representation/representationAgent.js @@ -196,7 +196,8 @@ const RepAgent = (props) => { "myrepresentations:add-files-label" )} ticketnumber={ - props.props.caseReference + props.currentView.caseReference + .ticketnumber } hint={"sdsd"} fileList={ diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js index 5dc66794..3b6950e7 100644 --- a/components/case/representation/representationAppellant.js +++ b/components/case/representation/representationAppellant.js @@ -188,7 +188,10 @@ const RepAppellant = (props) => { label={t( "myrepresentations:add-files-label" )} - ticketnumber={props.props.caseReference} + ticketnumber={ + props.currentView.caseReference + .ticketnumber + } hint={"sdsd"} fileList={ props.currentView.fileList diff --git a/components/case/representation/representationCapacitySelection.js b/components/case/representation/representationCapacitySelection.js index 25b5df15..31742d83 100644 --- a/components/case/representation/representationCapacitySelection.js +++ b/components/case/representation/representationCapacitySelection.js @@ -35,6 +35,9 @@ let RepCapacitySelection = (props) => { currentType={currentType} casesObj={casesObj} caseReference={props.props.caseReference} + ticketnumber={ + props.props.currentView.caseReference.ticketnumber + } searchResultsObj={props.props.searchResultsObj} myRepresentations={props.props.myRepresentations} props={props} diff --git a/components/case/representation/representationComplete.js b/components/case/representation/representationComplete.js index 0bfa4b12..4e8791c2 100644 --- a/components/case/representation/representationComplete.js +++ b/components/case/representation/representationComplete.js @@ -65,7 +65,7 @@ const RepComplete = (props) => { ), sendRepCompleteMessage( props.props.props.props.accountDetails.containerID, - props.props.currentView.caseReference.currentReference, + props.props.currentView.caseReference.ticketnumber, props.repFormData.repfile_name ), sendEmail(templateId, emailAddress, personalisation, reference), diff --git a/components/case/representation/representationDetails.js b/components/case/representation/representationDetails.js index 0276a089..ade7b9d0 100644 --- a/components/case/representation/representationDetails.js +++ b/components/case/representation/representationDetails.js @@ -10,7 +10,7 @@ const RepDetails = (props) => { const { currentType, casesObj } = props; - let { caseReference } = props; + let { caseReference, ticketnumber } = props; let setCaseDetailsObj = router.query.hasOwnProperty("state") ? router.query.state == "edit" @@ -29,7 +29,7 @@ const RepDetails = (props) => { : caseReference; detailsObj = jsonpath({ - path: '$..[?(@ && @.pinswg_name=="' + caseReference + '")]', + path: '$..[?(@ && @.ticketnumber=="' + ticketnumber + '")]', json: setCaseDetailsObj, eval: true, }); diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index 11c3cca6..6d0b41ca 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -188,7 +188,8 @@ const RepInterestedPartyPerson = (props) => { "myrepresentations:add-files-label" )} ticketnumber={ - props.props.caseReference + props.currentView.caseReference + .ticketnumber } hint={"sdsd"} fileList={ diff --git a/components/case/representation/representationLPA.js b/components/case/representation/representationLPA.js index 9818fe09..b543b284 100644 --- a/components/case/representation/representationLPA.js +++ b/components/case/representation/representationLPA.js @@ -353,7 +353,7 @@ let RepLPA = (props) => { "myrepresentations:add-files-label" )} ticketnumber={ - props.props.caseReference + props.currentView.caseReference.ticketnumber } hint={"sdsd"} fileList={ diff --git a/components/case/representation/representationLandowner.js b/components/case/representation/representationLandowner.js index 8029b788..90782bf6 100644 --- a/components/case/representation/representationLandowner.js +++ b/components/case/representation/representationLandowner.js @@ -84,7 +84,10 @@ const RepLandOwner = (props) => { label={t( "myrepresentations:add-files-label" )} - ticketnumber={props.props.caseReference} + ticketnumber={ + props.currentView.caseReference + .ticketnumber + } hint={"sdsd"} fileList={[]} setFilesForRepresentation={[]} diff --git a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js index d8fdfbe0..92437b28 100644 --- a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js +++ b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js @@ -1213,7 +1213,10 @@ let Enforcement_Questionnaire = (props) => { name={"representationDocuments"} id={"representationDocuments"} label={t("myrepresentations:add-files-label")} - ticketnumber={props.props.props.caseReference} + ticketnumber={ + props.props.currentView.caseReference + .ticketnumber + } hint={"sdsd"} fileList={ props.currentView.fileList diff --git a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_s78.js b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_s78.js index ae86e2b8..5c10936a 100644 --- a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_s78.js +++ b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_s78.js @@ -1022,7 +1022,10 @@ let S78_Questionnaire = (props) => { name={"representationDocuments"} id={"representationDocuments"} label={t("myrepresentations:add-files-label")} - ticketnumber={props.props.props.caseReference} + ticketnumber={ + props.props.currentView.caseReference + .ticketnumber + } hint={"sdsd"} fileList={ props.currentView.fileList diff --git a/components/case/summary.js b/components/case/summary.js index c39190c1..24225170 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -85,6 +85,7 @@ const CaseSummary = (props) => { currentView, messagesObj, docsOffline, + ticketnumber, } = props; const showLoginCheck = @@ -176,13 +177,13 @@ const CaseSummary = (props) => { currentType == "searchResultsObj" ? (casesObj = jsonpath({ - path: '$..[?(@ && @.title=="' + caseReference + '")]', + path: '$..[?(@ && @.ticketnumber=="' + ticketnumber + '")]', json: searchResultsObj, eval: true, })) : currentType == "watchedCases" ? (casesObj = jsonpath({ - path: '$..[?(@ && @.pinswg_title=="' + caseReference + '")]', + path: '$..[?(@ && @.ticketnumber=="' + ticketnumber + '")]', json: setCaseQueryObj, eval: true, })) @@ -194,7 +195,7 @@ const CaseSummary = (props) => { })) : currentType == "directResultsObj" ? (casesObj = jsonpath({ - path: '$..[?(@ && @.ticketnumber=="' + caseReference + '")]', + path: '$..[?(@ && @.ticketnumber=="' + ticketnumber + '")]', json: setCaseQueryObj, eval: true, })) @@ -466,13 +467,13 @@ const CaseSummary = (props) => { case: currentType == "searchResultsObj" - ? detailsObj.pinswg_name + ? detailsObj.ticketnumber : currentType == "watchedCases" ? casesObj.pinswg_title : currentType == "directResultsObj" - ? detailsObj.pinswg_name + ? detailsObj.ticketnumber : casesObj.reference, }, }}