reference ticket number not title, caters for long titles

This commit is contained in:
2026-02-20 11:58:35 +00:00
parent c438a62553
commit 5e46495e79
+64 -64
View File
@@ -14,7 +14,7 @@ import {
setRepresentationMessageSent, setRepresentationMessageSent,
setRepresentationReset, setRepresentationReset,
setRepresentationSubmit, setRepresentationSubmit,
setRepresentationSubmitConfirmation, setRepresentationSubmitConfirmation
} from "../../../store/currentView/action"; } from "../../../store/currentView/action";
import ConsultationAgent from "./consultationAgent"; import ConsultationAgent from "./consultationAgent";
import ConsultationAppellant from "./consultationAppellant"; import ConsultationAppellant from "./consultationAppellant";
@@ -66,7 +66,7 @@ let MakeRepresentation = (props) => {
initialValues, initialValues,
setCurrentReference, setCurrentReference,
ticketnumber, ticketnumber,
docsOffline, docsOffline
} = props; } = props;
const formObj = props.props.form; const formObj = props.props.form;
let setCaseQueryObj = props[currentType] || {}; let setCaseQueryObj = props[currentType] || {};
@@ -88,7 +88,7 @@ let MakeRepresentation = (props) => {
846040008: 7, 846040008: 7,
846040005: 9, 846040005: 9,
846040006: 9, 846040006: 9,
846040007: 9, 846040007: 9
}; };
return countMap[appealType] || 7; return countMap[appealType] || 7;
@@ -120,7 +120,7 @@ let MakeRepresentation = (props) => {
"Land Owner": "LO", "Land Owner": "LO",
lpa: "LPA", lpa: "LPA",
LPA: "LPA", LPA: "LPA",
NRW: "NRW", NRW: "NRW"
}; };
const repTypeMap = { const repTypeMap = {
@@ -133,16 +133,16 @@ let MakeRepresentation = (props) => {
"Consultation Response": "Consultation_Response", "Consultation Response": "Consultation_Response",
"Local Impact Report": "Local_Impact_Report", "Local Impact Report": "Local_Impact_Report",
"Marine Impact Report": "Marine_Impact_Report", "Marine Impact Report": "Marine_Impact_Report",
Other: "OTHER", Other: "OTHER"
}; };
const now = new Date(); const now = new Date();
const pad = (num) => String(num).padStart(2, "0"); const pad = (num) => String(num).padStart(2, "0");
const dateStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad( const dateStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(
now.getDate(), now.getDate()
)}-${pad(now.getHours())}:${pad(now.getMinutes())}:${pad( )}-${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(
now.getSeconds(), now.getSeconds()
)}`; )}`;
const repCap = repCapMap[values.representationCapacity] || ""; const repCap = repCapMap[values.representationCapacity] || "";
@@ -154,7 +154,7 @@ let MakeRepresentation = (props) => {
const namePart = isLPA const namePart = isLPA
? sanitize(values.onBehalfOfLPA || "") ? sanitize(values.onBehalfOfLPA || "")
: `${sanitize(values.lastname || "")}_${sanitize( : `${sanitize(values.lastname || "")}_${sanitize(
values.firstname || "", values.firstname || ""
)}`; )}`;
values.repfile_name = values.repfile_name =
@@ -171,17 +171,17 @@ let MakeRepresentation = (props) => {
case "searchResultsObj": case "searchResultsObj":
return { return {
path: `$..[?(@ && @.title=="${caseReference}")]`, path: `$..[?(@ && @.title=="${caseReference}")]`,
json: setCaseQueryObj, json: setCaseQueryObj
}; };
case "watchedCases": case "watchedCases":
return { return {
path: `$..[?(@ && @.ticketnumber=="${caseReference}")]`, path: `$..[?(@ && @.ticketnumber=="${caseReference}")]`,
json: watchedCases, json: watchedCases
}; };
default: default:
return { return {
path: `$..[?(@ && @.reference=="${caseReference}")]`, path: `$..[?(@ && @.reference=="${caseReference}")]`,
json: setCaseQueryObj, json: setCaseQueryObj
}; };
} }
}; };
@@ -194,7 +194,7 @@ let MakeRepresentation = (props) => {
const capacityOptionsArr = [ const capacityOptionsArr = [
t("myrepresentations:capacity-options-arr-appellant"), t("myrepresentations:capacity-options-arr-appellant"),
t("myrepresentations:capacity-options-arr-agent"), t("myrepresentations:capacity-options-arr-agent")
]; ];
const shouldIncludeInterested = const shouldIncludeInterested =
@@ -203,7 +203,7 @@ let MakeRepresentation = (props) => {
if (shouldIncludeInterested) { if (shouldIncludeInterested) {
capacityOptionsArr.push( capacityOptionsArr.push(
t("myrepresentations:capacity-options-arr-interested"), t("myrepresentations:capacity-options-arr-interested")
); );
} }
@@ -238,7 +238,7 @@ let MakeRepresentation = (props) => {
let resultsObj = jsonpath({ let resultsObj = jsonpath({
path: `$..[?(@ && @.ticketnumber=="${currentView.caseReference.currentReference}")]`, path: `$..[?(@ && @.ticketnumber=="${currentView.caseReference.currentReference}")]`,
json: setCaseResultsObj, json: setCaseResultsObj,
eval: true, eval: true
})[0]; })[0];
// let detailsObj; // let detailsObj;
@@ -247,13 +247,13 @@ let MakeRepresentation = (props) => {
detailsObj = jsonpath({ detailsObj = jsonpath({
path: `$..[?(@ && @.repfile_name=="${router.query.created}")]`, path: `$..[?(@ && @.repfile_name=="${router.query.created}")]`,
json: setCaseDetailsObj, json: setCaseDetailsObj,
eval: true, eval: true
})[0]; })[0];
} else { } else {
detailsObj = jsonpath({ detailsObj = jsonpath({
path: `$..[?(@ && @.pinswg_name=="${currentView.caseReference.currentReference}")]`, path: `$..[?(@ && @.ticketnumber=="${currentView.caseReference.ticketnumber}")]`,
json: setCaseDetailsObj, json: setCaseDetailsObj,
eval: true, eval: true
})[0]; })[0];
} }
@@ -269,20 +269,20 @@ let MakeRepresentation = (props) => {
const startDate = new Date( const startDate = new Date(
isDNS isDNS
? detailsObj.pinswg_applicationacceptedasvalid ? detailsObj.pinswg_applicationacceptedasvalid
: detailsObj.pinswg_startdate || detailsObj.pinswg_startdates, : detailsObj.pinswg_startdate || detailsObj.pinswg_startdates
); );
const questionnaireDate = new Date( const questionnaireDate = new Date(
isDNS isDNS
? detailsObj.pinswg_endofrepresentationperiod ? detailsObj.pinswg_endofrepresentationperiod
: detailsObj.pinswg_questionnaireduedate, : detailsObj.pinswg_questionnaireduedate
); );
questionnaireDate.setHours(23, 59, 59, 999); questionnaireDate.setHours(23, 59, 59, 999);
const finalCommentsDate = new Date( const finalCommentsDate = new Date(
isDNS isDNS
? detailsObj.pinswg_endofrepresentationperiod ? detailsObj.pinswg_endofrepresentationperiod
: detailsObj.pinswg_finalcommentsduedate, : detailsObj.pinswg_finalcommentsduedate
); );
finalCommentsDate.setHours(23, 59, 59, 999); finalCommentsDate.setHours(23, 59, 59, 999);
@@ -290,7 +290,7 @@ let MakeRepresentation = (props) => {
isDNS isDNS
? detailsObj.pinswg_endofrepresentationperiod ? detailsObj.pinswg_endofrepresentationperiod
: detailsObj.pinswg_statementduedate || : detailsObj.pinswg_statementduedate ||
detailsObj.pinswg_statementsduedate, detailsObj.pinswg_statementsduedate
); );
statementDueDate.setHours(23, 59, 59, 999); statementDueDate.setHours(23, 59, 59, 999);
@@ -407,7 +407,7 @@ let MakeRepresentation = (props) => {
updateRepresentation, updateRepresentation,
setSavingStatus, setSavingStatus,
savingStatus, savingStatus,
setCurrentReference, setCurrentReference
}; };
const getNormalizedCapacity = () => { const getNormalizedCapacity = () => {
@@ -447,7 +447,7 @@ let MakeRepresentation = (props) => {
case "apelydd": case "apelydd":
case "apelydd": case "apelydd":
case t( case t(
"myrepresentations:capacity-options-arr-appellant", "myrepresentations:capacity-options-arr-appellant"
).toLowerCase(): { ).toLowerCase(): {
const Component = const Component =
appealType === 846040002 appealType === 846040002
@@ -457,7 +457,7 @@ let MakeRepresentation = (props) => {
<Component <Component
{...commonProps} {...commonProps}
appellantApplicantRepresentationArr={buildRepsArr( appellantApplicantRepresentationArr={buildRepsArr(
detailsObj, detailsObj
)} )}
/> />
); );
@@ -469,7 +469,7 @@ let MakeRepresentation = (props) => {
<RepLPA <RepLPA
{...commonProps} {...commonProps}
appellantApplicantRepresentationArr={buildRepsArr( appellantApplicantRepresentationArr={buildRepsArr(
detailsObj, detailsObj
)} )}
setShowQuestionnaireSection={ setShowQuestionnaireSection={
setShowQuestionnaireSection setShowQuestionnaireSection
@@ -484,7 +484,7 @@ let MakeRepresentation = (props) => {
case "asiant": case "asiant":
case "asiant": case "asiant":
case t( case t(
"myrepresentations:capacity-options-arr-agent", "myrepresentations:capacity-options-arr-agent"
).toLowerCase(): { ).toLowerCase(): {
const Component = const Component =
appealType === 846040002 ? ConsultationAgent : RepAgent; appealType === 846040002 ? ConsultationAgent : RepAgent;
@@ -492,7 +492,7 @@ let MakeRepresentation = (props) => {
<Component <Component
{...commonProps} {...commonProps}
appellantApplicantRepresentationArr={buildRepsArr( appellantApplicantRepresentationArr={buildRepsArr(
detailsObj, detailsObj
)} )}
/> />
); );
@@ -500,7 +500,7 @@ let MakeRepresentation = (props) => {
case "interestedparty": case "interestedparty":
case t( case t(
"myrepresentations:capacity-options-arr-interested", "myrepresentations:capacity-options-arr-interested"
).toLowerCase(): { ).toLowerCase(): {
const Component = const Component =
appealType === 846040002 appealType === 846040002
@@ -510,7 +510,7 @@ let MakeRepresentation = (props) => {
<Component <Component
{...commonProps} {...commonProps}
interestedPersonRepresentationArr={buildRepsArr( interestedPersonRepresentationArr={buildRepsArr(
detailsObj, detailsObj
)} )}
/> />
); );
@@ -545,12 +545,12 @@ let MakeRepresentation = (props) => {
currentView, currentView,
showQuestionnaireSection, showQuestionnaireSection,
setShowQuestionnaireSection, setShowQuestionnaireSection,
questionnaireCount, questionnaireCount
}; };
const s78AppealTypes = [ const s78AppealTypes = [
846040000, 846040001, 846040025, 846040004, 846040018, 846040003, 846040000, 846040001, 846040025, 846040004, 846040018, 846040003,
846040009, 846040008, 846040017, 846040009, 846040008, 846040017
]; ];
const enforcementAppealTypes = [846040005, 846040006, 846040007]; const enforcementAppealTypes = [846040005, 846040006, 846040007];
@@ -613,7 +613,7 @@ let MakeRepresentation = (props) => {
detailsObj?.pinswg_siteaddresspostcode || detailsObj?.pinswg_siteaddresspostcode ||
detailsObj?.pinswg_postcode, detailsObj?.pinswg_postcode,
detailsObj?.pinswg_siteaddresscounty || detailsObj?.pinswg_siteaddresscounty ||
detailsObj?.pinswg_addresscounty, detailsObj?.pinswg_addresscounty
] ]
.filter((v) => !!v && v.trim()) // remove empty/whitespace-only values .filter((v) => !!v && v.trim()) // remove empty/whitespace-only values
.map((v) => toTitleCase(v.trim())) // title-case each segment .map((v) => toTitleCase(v.trim())) // title-case each segment
@@ -622,13 +622,13 @@ let MakeRepresentation = (props) => {
const updateRepresentation = async ( const updateRepresentation = async (
values, values,
sendSavedEmail, sendSavedEmail,
useSaveStatus, useSaveStatus
) => { ) => {
const { const {
appealType: appealTypeProp, appealType: appealTypeProp,
currentView, currentView,
accountDetails, accountDetails,
loggedinUserEmail, loggedinUserEmail
} = props.props; } = props.props;
const incidentID = props.appealType.caseReference.incidentid; const incidentID = props.appealType.caseReference.incidentid;
const currentRef = caseReferenceObj.currentReference; const currentRef = caseReferenceObj.currentReference;
@@ -641,13 +641,13 @@ let MakeRepresentation = (props) => {
pinswg_siteaddressline1, pinswg_siteaddressline1,
pinswg_siteaddressline2, pinswg_siteaddressline2,
pinswg_siteaddresstown, pinswg_siteaddresstown,
pinswg_siteaddresspostcode, pinswg_siteaddresspostcode
} = detailsObj; } = detailsObj;
return [ return [
pinswg_siteaddressline1, pinswg_siteaddressline1,
pinswg_siteaddressline2, pinswg_siteaddressline2,
pinswg_siteaddresstown, pinswg_siteaddresstown,
pinswg_siteaddresspostcode, pinswg_siteaddresspostcode
] ]
.filter(Boolean) .filter(Boolean)
.join(" "); .join(" ");
@@ -692,7 +692,7 @@ let MakeRepresentation = (props) => {
pinswg_siteaddresspostcode: detailsObj.pinswg_siteaddresspostcode, pinswg_siteaddresspostcode: detailsObj.pinswg_siteaddresspostcode,
pinswg_lpareference: resultsObj?.pinswg_lpareference, pinswg_lpareference: resultsObj?.pinswg_lpareference,
representationCapacity: getRepresentationCapacity(), representationCapacity: getRepresentationCapacity(),
locale: router.locale, locale: router.locale
}; };
const formattedValues = { const formattedValues = {
@@ -712,7 +712,7 @@ let MakeRepresentation = (props) => {
] || ] ||
detailsObj[ detailsObj[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
], ]
}; };
let updateBody = setRepFileName(formattedValues); let updateBody = setRepFileName(formattedValues);
@@ -725,7 +725,7 @@ let MakeRepresentation = (props) => {
} }
return acc; return acc;
}, },
{}, {}
); );
// Normalize "Yes"/"No" to booleans // Normalize "Yes"/"No" to booleans
@@ -742,13 +742,13 @@ let MakeRepresentation = (props) => {
caseReference: props.caseReference, caseReference: props.caseReference,
emailAddress: loggedinUserEmail, emailAddress: loggedinUserEmail,
returnLink: "", returnLink: "",
linkExpiry: 600, // 10 minutes linkExpiry: 600 // 10 minutes
}; };
sendEmail( sendEmail(
templateId, templateId,
loggedinUserEmail, loggedinUserEmail,
personalisation, personalisation,
reference, reference
); );
} }
}; };
@@ -764,7 +764,7 @@ let MakeRepresentation = (props) => {
const handleFileUpload = () => { const handleFileUpload = () => {
const filesWithLinks = updateLinks({ const filesWithLinks = updateLinks({
...values, ...values,
filesList: currentView.fileList, filesList: currentView.fileList
}); });
uploadRepresentationFiles(filesWithLinks); uploadRepresentationFiles(filesWithLinks);
}; };
@@ -803,7 +803,7 @@ let MakeRepresentation = (props) => {
let detailsObj = jsonpath({ let detailsObj = jsonpath({
path: `$..[?(@ && @.pinswg_name=="${caseReference}")]`, path: `$..[?(@ && @.pinswg_name=="${caseReference}")]`,
json: setCaseDetailsObj, json: setCaseDetailsObj,
eval: true, eval: true
})[0]; })[0];
// Cancel submit status if editing // Cancel submit status if editing
@@ -823,13 +823,13 @@ let MakeRepresentation = (props) => {
pinswg_siteaddressline1, pinswg_siteaddressline1,
pinswg_siteaddressline2, pinswg_siteaddressline2,
pinswg_siteaddresstown, pinswg_siteaddresstown,
pinswg_siteaddresspostcode, pinswg_siteaddresspostcode
} = detailsObj; } = detailsObj;
return [ return [
pinswg_siteaddressline1, pinswg_siteaddressline1,
pinswg_siteaddressline2, pinswg_siteaddressline2,
pinswg_siteaddresstown, pinswg_siteaddresstown,
pinswg_siteaddresspostcode, pinswg_siteaddresspostcode
] ]
.filter(Boolean) .filter(Boolean)
.join(" "); .join(" ");
@@ -889,7 +889,7 @@ let MakeRepresentation = (props) => {
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
], ],
representationCapacity, representationCapacity,
locale: router.locale, locale: router.locale
}); });
} }
@@ -916,7 +916,7 @@ let MakeRepresentation = (props) => {
showQuestionnaireSection < questionnaireCount showQuestionnaireSection < questionnaireCount
) { ) {
setShowQuestionnaireSection( setShowQuestionnaireSection(
showQuestionnaireSection + 1, showQuestionnaireSection + 1
); );
updateRepresentation(values, false, false); updateRepresentation(values, false, false);
} else { } else {
@@ -937,7 +937,7 @@ let MakeRepresentation = (props) => {
Object.assign(values, { Object.assign(values, {
locale: router.locale, locale: router.locale,
repComplete: currentView.caseReference.currentReference, repComplete: currentView.caseReference.currentReference
}); });
if (props.invalid === false) { if (props.invalid === false) {
@@ -949,7 +949,7 @@ let MakeRepresentation = (props) => {
generateRepPDF( generateRepPDF(
values, values,
props.props.accountDetails.containerID, props.props.accountDetails.containerID,
currentView.caseReference.currentReference, currentView.caseReference.currentReference
).then((data) => { ).then((data) => {
if (data.status === "success") { if (data.status === "success") {
values = updateLinks(values); values = updateLinks(values);
@@ -968,13 +968,13 @@ let MakeRepresentation = (props) => {
(file) => (file) =>
file && file &&
typeof file === "object" && typeof file === "object" &&
Object.keys(file).length > 0, Object.keys(file).length > 0
) )
.filter((file) => file.name !== undefined); .filter((file) => file.name !== undefined);
return { return {
...blobList, ...blobList,
filesList: cleanedFiles, filesList: cleanedFiles
}; };
}; };
@@ -1003,7 +1003,7 @@ let MakeRepresentation = (props) => {
dataObj, dataObj,
[{}], [{}],
updatedValues.containerID, updatedValues.containerID,
`${props.caseReference}/${dataObj.repfile_name}`, `${props.caseReference}/${dataObj.repfile_name}`
); );
}; };
@@ -1027,7 +1027,7 @@ let MakeRepresentation = (props) => {
return formatDates( return formatDates(
detailsObj.pinswg_questionnaireduedate || detailsObj.pinswg_questionnaireduedate ||
detailsObj.pinswg_endofrepresentationperiod || detailsObj.pinswg_endofrepresentationperiod ||
detailsObj.pinswg_consultationclose, detailsObj.pinswg_consultationclose
); );
} }
return "N/A"; return "N/A";
@@ -1040,7 +1040,7 @@ let MakeRepresentation = (props) => {
{formatDates( {formatDates(
detailsObj.pinswg_statementduedate || detailsObj.pinswg_statementduedate ||
detailsObj.pinswg_statementsduedate || detailsObj.pinswg_statementsduedate ||
detailsObj.pinswg_endofrepresentationperiod, detailsObj.pinswg_endofrepresentationperiod
)} )}
</span> </span>
</div> </div>
@@ -1114,10 +1114,10 @@ let MakeRepresentation = (props) => {
<h1 className="govuk-heading-l"> <h1 className="govuk-heading-l">
{appealIsConsultation {appealIsConsultation
? t( ? t(
"myrepresentations:make-a-consultation-on-label", "myrepresentations:make-a-consultation-on-label"
) )
: t( : t(
"myrepresentations:make-a-representation-on-label", "myrepresentations:make-a-representation-on-label"
)}{" "} )}{" "}
{currentView.caseReference.currentReference}{" "} {currentView.caseReference.currentReference}{" "}
</h1> </h1>
@@ -1131,17 +1131,17 @@ let MakeRepresentation = (props) => {
<div className="card-body"> <div className="card-body">
<h2 className="govuk-heading-s"> <h2 className="govuk-heading-s">
{t( {t(
"myrepresentations:timetable-title", "myrepresentations:timetable-title"
)} )}
</h2> </h2>
<div className="govuk-summary-list"> <div className="govuk-summary-list">
<div className="govuk-body-s"> <div className="govuk-body-s">
{appealIsLocalImpact {appealIsLocalImpact
? t( ? t(
"myrepresentations:local-impact-report", "myrepresentations:local-impact-report"
) )
: t( : t(
"myrepresentations:questionnaire-due-label", "myrepresentations:questionnaire-due-label"
)} )}
:{" "} :{" "}
<span className="govuk-body-s"> <span className="govuk-body-s">
@@ -1179,7 +1179,7 @@ const mapStateToProps = (state) => {
appealType: state.appealType, appealType: state.appealType,
currentView: state.currentView, currentView: state.currentView,
myRepresentations: state.myRepresentations, myRepresentations: state.myRepresentations,
initialValues: state.currentView.caseReference.repDetails, initialValues: state.currentView.caseReference.repDetails
//form: state.form, //form: state.form,
}; };
}; };
@@ -1203,7 +1203,7 @@ const mapDispatchToProps = (dispatch) => {
}, },
setRepresentationReset: () => { setRepresentationReset: () => {
dispatch(setRepresentationReset()); dispatch(setRepresentationReset());
}, }
}; };
}; };
@@ -1211,11 +1211,11 @@ const selector = formValueSelector("representationForm");
export default connect( export default connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps, mapDispatchToProps
)( )(
reduxForm({ reduxForm({
form: "representationForm", form: "representationForm",
destroyOnUnmount: false, destroyOnUnmount: false,
enableReinitialize: true, enableReinitialize: true
})(MakeRepresentation), })(MakeRepresentation)
); );