Merged PR 2291: reps array refactor and update and tests

reps array refactor and update and tests

Related work items: #22873
This commit is contained in:
Robert Bond
2026-05-05 10:16:27 +00:00
parent 0ff2d69ba6
commit 46a0e0b185
4 changed files with 689 additions and 141 deletions
+17 -141
View File
@@ -52,6 +52,10 @@ import {
buildSubmitEnrichedValues,
runFinalisationSequence
} from "./utils/finalisationBoundary";
import {
buildRepresentationContext,
buildRepsArrFromContext
} from "./utils/buildRepsArrRules";
let MakeRepresentation = (props) => {
let { t } = useTranslation();
@@ -313,152 +317,24 @@ let MakeRepresentation = (props) => {
const safeResultsObj = resultsObj || {};
const buildRepsArr = (detailsObj) => {
const buildArr = [];
const todaysDate = new Date();
const isDNS = appealType === 846040011;
const isSIPS = appealType === 846040002;
const specialistProcess = currentView.caseReference.specialistProcess;
const isSpecialistNonHearing = specialistProcess !== 846040001;
const involvementType =
props.props?.accountDetails?.accountDetails
?.pinswg_typeofinvolvement;
//const isAppellant = involvementType === 846040001;
const isAppellant =
const isCaseOwner =
props.props.accountDetails.accountDetails.emailaddress1 ==
props.searchResultsObj?.searchResultsObj?.value[0]
.customerid_contact.emailaddress1;
const isAgent = involvementType === 846040000;
const isIP = involvementType === 846040061;
const isLPA = involvementType === 846040012;
const ctx = buildRepresentationContext({
detailsObj,
appealType,
specialistProcess: currentView.caseReference.specialistProcess,
involvementType:
props.props?.accountDetails?.accountDetails
?.pinswg_typeofinvolvement,
selectedCapacity: repCapacityType(),
isCaseOwner,
isNRW
});
const startDate = new Date(
isDNS
? detailsObj.pinswg_applicationacceptedasvalid
: detailsObj.pinswg_startdate || detailsObj.pinswg_startdates
);
const finalCommentsDate = new Date(
isDNS
? detailsObj.pinswg_endofrepresentationperiod
: detailsObj.pinswg_finalcommentsduedate
);
finalCommentsDate.setHours(23, 59, 59, 999);
const statementDueDate = new Date(
isDNS
? detailsObj.pinswg_endofrepresentationperiod
: detailsObj.pinswg_statementduedate ||
detailsObj.pinswg_statementsduedate
);
statementDueDate.setHours(23, 59, 59, 999);
const isWithin = (start, end) =>
todaysDate >= start && todaysDate <= end;
const addRep = (value) => {
if (!buildArr.includes(value)) {
buildArr.push(value);
}
};
const canAddQuestionnaire =
isLPA &&
![846040019, 846040011, 846040015, 846040016].includes(
appealType
) &&
isWithin(startDate, finalCommentsDate);
if (canAddQuestionnaire) {
addRep("Questionnaire");
}
const isLpaAdvertPart3NoStatement =
isLPA &&
appealType === 846040018 &&
specialistProcess === 846040000;
const canAddDnsLpaDocs =
isLPA &&
isDNS &&
appealType !== 846040019 &&
!isAppellant &&
isWithin(startDate, finalCommentsDate);
if (canAddDnsLpaDocs) {
addRep("Local Impact Report");
addRep("Statement");
}
const canAddStatementForNonDns =
!isDNS &&
appealType !== 846040004 &&
!isLpaAdvertPart3NoStatement &&
!isAppellant &&
isWithin(startDate, statementDueDate);
if (canAddStatementForNonDns) {
addRep("Statement");
}
const canAddStatementForDnsNonLpa =
isDNS &&
!isLPA &&
!isAppellant &&
isWithin(startDate, statementDueDate);
if (canAddStatementForDnsNonLpa) {
addRep("Statement");
}
const canSubmitFinalComments = isAppellant || isAgent || isIP || isLPA;
const canAddFinalComments =
canSubmitFinalComments &&
isWithin(statementDueDate, finalCommentsDate) &&
(appealType !== 846040004 || isSpecialistNonHearing);
// IP and Agents and LPA can do final comments.
if (canAddFinalComments) {
addRep("Final comments");
}
if (isSIPS) {
const capacity = repCapacityType();
addRep("Consultation Response");
if (capacity !== "appellant") {
addRep("Local Impact Report");
}
if (isNRW) {
addRep("Marine Impact Report");
}
}
console.log(
"======================================\n\n",
"isAgent: " + isAgent,
"\n",
"isIP: " + isIP,
"\n",
"isLPA: " + isLPA,
"\n",
"isAppellant: " + isAppellant,
"\n\n======================================\n\n",
"options: ",
buildArr,
"\n\n======================================\n\n"
);
return buildArr;
return buildRepsArrFromContext(ctx);
};
const repCapacityType = () => {