Files
pedwfrontend/components/case/summary/utils/representationEntry.js
T
Robert Bond e195e09429 Merged PR 2407: Extract representation entry specialist rules to domain policy
Extract representation entry specialist rules to domain policy

Related work items: #23754
2026-06-19 11:21:17 +00:00

90 lines
2.4 KiB
JavaScript

import {
resolveRepresentationWindow,
isRepresentationWindowOpen,
isRepresentationWindowClosed,
canShowRepresentationButtonForAppealType,
canStartHouseholderRepresentation,
canStartCpoRepresentation,
canStartRowRepresentation,
canStartAdvertRepresentation
} from "../../../../lib/domain/representation-policy";
export function showRepsLocal(startDate, endDate) {
return isRepresentationWindowOpen(startDate, endDate);
}
export function showRepsEndedLocal(startDate, endDate) {
return isRepresentationWindowClosed(startDate, endDate);
}
export function isConsultationWindowOpen(detailsObj) {
return showRepsLocal(
detailsObj.pinswg_consultationopen,
detailsObj.pinswg_consultationclose
);
}
export function isGeneralRepresentationWindowOpen(detailsObj) {
return resolveRepresentationWindow(detailsObj).isOpen;
}
export function canShowRepButtonForAppealType({
appealType,
isLPA,
searchDetailsObj
}) {
if (!canShowRepresentationButtonForAppealType(appealType)) {
return false;
}
switch (appealType) {
case 846040004:
return canStartHouseholderRepresentation(appealType, isLPA);
case 846040015:
return canStartRowRepresentation(
appealType,
searchDetailsObj[0].value[0]
);
case 846040018:
return canStartAdvertRepresentation(
appealType,
searchDetailsObj[0].value[0],
isLPA
);
case 846040019:
return canStartCpoRepresentation(
appealType,
searchDetailsObj[0].value[0]
);
default:
return true;
}
}
export function getEntryCtaLabelKey(appealType) {
return appealType == 846040002
? "case:summary-make-consultation-label"
: "case:summary-make-representation-label";
}
export function shouldSuppressBlockedMessage({ appealType, isLPA }) {
return !isLPA && appealType == 846040004;
}
export function getGeneralBlockedEndDate(detailsObj, appealType) {
return appealType == 846040019
? detailsObj.pinswg_statementduedate
: detailsObj.pinswg_finalcommentsduedate;
}
export function isRepresentationPeriodEnded(detailsObj) {
return showRepsEndedLocal(
detailsObj.pinswg_startdate,
detailsObj.pinswg_finalcommentsduedate
);
}