Merged PR 2405: Representation Entry Policy discovery and wrapper
Related work items: #23754
This commit is contained in:
@@ -52,10 +52,8 @@ import {
|
||||
buildSubmitEnrichedValues,
|
||||
runFinalisationSequence
|
||||
} from "./utils/finalisationBoundary";
|
||||
import {
|
||||
buildRepresentationContext,
|
||||
buildRepsArrFromContext
|
||||
} from "./utils/buildRepsArrRules";
|
||||
import { buildRepresentationContext } from "./utils/buildRepsArrRules";
|
||||
import { getAvailableRepresentationTypes } from "../../../lib/domain/representation-type-policy/getAvailableRepresentationTypes";
|
||||
|
||||
let MakeRepresentation = (props) => {
|
||||
let { t } = useTranslation();
|
||||
@@ -334,7 +332,7 @@ let MakeRepresentation = (props) => {
|
||||
isNRW
|
||||
});
|
||||
|
||||
return buildRepsArrFromContext(ctx);
|
||||
return getAvailableRepresentationTypes(ctx);
|
||||
};
|
||||
|
||||
const repCapacityType = () => {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
const {
|
||||
getAvailableRepresentationTypes
|
||||
} = require("../../../../lib/domain/representation-type-policy/getAvailableRepresentationTypes");
|
||||
|
||||
export const APPEAL_TYPES = {
|
||||
SIPS: 846040002,
|
||||
DNS: 846040011,
|
||||
@@ -110,115 +114,6 @@ export const buildRepresentationContext = ({
|
||||
};
|
||||
};
|
||||
|
||||
export const addQuestionnaire = (options, ctx) => {
|
||||
const excludedTypes = [
|
||||
APPEAL_TYPES.EXCLUDE_QUESTIONNAIRE_1,
|
||||
APPEAL_TYPES.DNS,
|
||||
APPEAL_TYPES.EXCLUDE_QUESTIONNAIRE_2,
|
||||
APPEAL_TYPES.EXCLUDE_QUESTIONNAIRE_3
|
||||
];
|
||||
|
||||
const canAdd =
|
||||
ctx.isLPA &&
|
||||
!excludedTypes.includes(ctx.appealType) &&
|
||||
isWithinWindow(ctx.now, ctx.startDate, ctx.finalCommentsDueDate);
|
||||
|
||||
if (canAdd) {
|
||||
options.add(REPRESENTATION_OPTIONS.QUESTIONNAIRE);
|
||||
}
|
||||
};
|
||||
|
||||
export const addStatements = (options, ctx) => {
|
||||
const isLpaAdvertPart3NoStatement =
|
||||
ctx.isLPA &&
|
||||
ctx.appealType === APPEAL_TYPES.ADVERT &&
|
||||
ctx.specialistProcess === SPECIALIST_PROCESS.WRITTEN_REPS;
|
||||
|
||||
const canAddDnsLpaDocs =
|
||||
ctx.isLPA &&
|
||||
ctx.isDNS &&
|
||||
ctx.appealType !== APPEAL_TYPES.EXCLUDE_QUESTIONNAIRE_1 &&
|
||||
!ctx.isCaseOwner &&
|
||||
isWithinWindow(ctx.now, ctx.startDate, ctx.finalCommentsDueDate);
|
||||
|
||||
if (canAddDnsLpaDocs) {
|
||||
options.add(REPRESENTATION_OPTIONS.LOCAL_IMPACT_REPORT);
|
||||
options.add(REPRESENTATION_OPTIONS.STATEMENT);
|
||||
}
|
||||
|
||||
const canAddStatementForNonDns =
|
||||
!ctx.isDNS &&
|
||||
ctx.appealType !== APPEAL_TYPES.HOUSEHOLDER &&
|
||||
!isLpaAdvertPart3NoStatement &&
|
||||
!ctx.isCaseOwner &&
|
||||
isWithinWindow(ctx.now, ctx.startDate, ctx.statementDueDate);
|
||||
|
||||
if (canAddStatementForNonDns) {
|
||||
options.add(REPRESENTATION_OPTIONS.STATEMENT);
|
||||
}
|
||||
|
||||
const canAddStatementForDnsNonLpa =
|
||||
ctx.isDNS &&
|
||||
!ctx.isLPA &&
|
||||
!ctx.isCaseOwner &&
|
||||
isWithinWindow(ctx.now, ctx.startDate, ctx.statementDueDate);
|
||||
|
||||
if (canAddStatementForDnsNonLpa) {
|
||||
options.add(REPRESENTATION_OPTIONS.STATEMENT);
|
||||
}
|
||||
};
|
||||
|
||||
export const addFinalComments = (options, ctx) => {
|
||||
const canSubmitFinalCommentsDefault =
|
||||
ctx.isSelectedAppellant ||
|
||||
ctx.isSelectedAgent ||
|
||||
ctx.isSelectedInterestedParty ||
|
||||
ctx.isLPA;
|
||||
|
||||
const canSubmitFinalComments = ctx.isDNS
|
||||
? ctx.isLPA
|
||||
: canSubmitFinalCommentsDefault;
|
||||
|
||||
const isSpecialistNonHearing =
|
||||
ctx.specialistProcess !== SPECIALIST_PROCESS.HEARING;
|
||||
|
||||
const finalCommentsWindowStart = ctx.isDNS
|
||||
? ctx.startDate
|
||||
: ctx.statementDueDate;
|
||||
|
||||
const canAdd =
|
||||
canSubmitFinalComments &&
|
||||
isWithinWindow(
|
||||
ctx.now,
|
||||
finalCommentsWindowStart,
|
||||
ctx.finalCommentsDueDate
|
||||
) &&
|
||||
(ctx.appealType !== APPEAL_TYPES.HOUSEHOLDER || isSpecialistNonHearing);
|
||||
|
||||
if (canAdd) {
|
||||
options.add(REPRESENTATION_OPTIONS.FINAL_COMMENTS);
|
||||
}
|
||||
};
|
||||
|
||||
export const addConsultation = (options, ctx) => {
|
||||
if (!ctx.isSIPS) return;
|
||||
|
||||
options.add(REPRESENTATION_OPTIONS.CONSULTATION_RESPONSE);
|
||||
|
||||
if (!ctx.isSelectedAppellant) {
|
||||
options.add(REPRESENTATION_OPTIONS.LOCAL_IMPACT_REPORT);
|
||||
}
|
||||
|
||||
if (ctx.isNRW) {
|
||||
options.add(REPRESENTATION_OPTIONS.MARINE_IMPACT_REPORT);
|
||||
}
|
||||
};
|
||||
|
||||
export const buildRepsArrFromContext = (ctx) => {
|
||||
const options = new Set();
|
||||
addQuestionnaire(options, ctx);
|
||||
addStatements(options, ctx);
|
||||
addFinalComments(options, ctx);
|
||||
addConsultation(options, ctx);
|
||||
return [...options];
|
||||
return getAvailableRepresentationTypes(ctx);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user