Merged PR 2252: refactor(representations): extract journey step-resolution helpers (Slice R3,...
refactor(representations): extract journey step-resolution helpers (Slice R3, behaviour-preserving) Related work items: #22441
This commit is contained in:
@@ -33,6 +33,12 @@ import RepLPACapacitySelection from "./representationLPACapacitySelection";
|
||||
import RepLandOwner from "./representationLandowner";
|
||||
import RepresentationProgress_enforcement from "./representationProgress/representationProgress_enforcement";
|
||||
import RepresentationProgress_s78 from "./representationProgress/representationProgress_s78";
|
||||
import {
|
||||
getQuestionnaireNextSection,
|
||||
resolveJourneyStageFlags,
|
||||
resolveRepresentationControlKey,
|
||||
resolveSubmitTransition
|
||||
} from "./utils/stepResolution";
|
||||
|
||||
let MakeRepresentation = (props) => {
|
||||
let { t } = useTranslation();
|
||||
@@ -105,6 +111,11 @@ let MakeRepresentation = (props) => {
|
||||
: false;
|
||||
|
||||
const isNRW = currentView.caseReference?.isNRW;
|
||||
const { showCheckStage } = resolveJourneyStageFlags({
|
||||
"representationSubmit": currentView.representationSubmit,
|
||||
"representationSubmitConfirmation":
|
||||
currentView.representationSubmitConfirmation
|
||||
});
|
||||
|
||||
const setRepFileName = (values) => {
|
||||
if (
|
||||
@@ -586,19 +597,16 @@ let MakeRepresentation = (props) => {
|
||||
setCurrentReference
|
||||
};
|
||||
|
||||
const getNormalizedCapacity = () => {
|
||||
const rawCapacity =
|
||||
currentView.representationCapacity ||
|
||||
currentView.caseReference?.repDetails?.representationCapacity ||
|
||||
"false";
|
||||
return rawCapacity.toLowerCase();
|
||||
};
|
||||
const { controlKey } = resolveRepresentationControlKey({
|
||||
"isLPA": isLPA,
|
||||
"representationCapacity": currentView.representationCapacity,
|
||||
"repDetailsCapacity":
|
||||
currentView.caseReference?.repDetails?.representationCapacity,
|
||||
"appealType": appealType,
|
||||
"normalizeCapacity": normalizeCapacity
|
||||
});
|
||||
|
||||
if (
|
||||
isLPA &&
|
||||
(!currentView.representationCapacity ||
|
||||
currentView.representationCapacity === "")
|
||||
) {
|
||||
if (controlKey === "lpa-capacity-selection") {
|
||||
return (
|
||||
<RepLPACapacitySelection
|
||||
{...commonProps}
|
||||
@@ -616,10 +624,8 @@ let MakeRepresentation = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
const capacity = normalizeCapacity(getNormalizedCapacity());
|
||||
|
||||
switch (capacity) {
|
||||
case "appellant": {
|
||||
switch (controlKey) {
|
||||
case "capacity-appellant": {
|
||||
const Component =
|
||||
appealType === 846040002
|
||||
? ConsultationAppellant
|
||||
@@ -634,7 +640,7 @@ let MakeRepresentation = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
case "lpa": {
|
||||
case "capacity-lpa": {
|
||||
return (
|
||||
<RepLPA
|
||||
{...commonProps}
|
||||
@@ -650,7 +656,7 @@ let MakeRepresentation = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
case "agent": {
|
||||
case "capacity-agent": {
|
||||
const Component =
|
||||
appealType === 846040002 ? ConsultationAgent : RepAgent;
|
||||
return (
|
||||
@@ -663,7 +669,7 @@ let MakeRepresentation = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
case "interestedparty": {
|
||||
case "capacity-interestedparty": {
|
||||
const Component =
|
||||
appealType === 846040002
|
||||
? ConsultationInterestedPartyPerson
|
||||
@@ -678,7 +684,7 @@ let MakeRepresentation = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
case "landowner": {
|
||||
case "capacity-landowner": {
|
||||
return (
|
||||
<RepLandOwner
|
||||
{...commonProps}
|
||||
@@ -1078,19 +1084,20 @@ let MakeRepresentation = (props) => {
|
||||
: normalizeCapacity(values.representationCapacity);
|
||||
setRepresentationCapacity(capacity);
|
||||
} else {
|
||||
if (repType === "Questionnaire") {
|
||||
if (
|
||||
questionnaireCount !== 0 &&
|
||||
showQuestionnaireSection < questionnaireCount
|
||||
) {
|
||||
setShowQuestionnaireSection(
|
||||
showQuestionnaireSection + 1
|
||||
);
|
||||
updateRepresentation(values, false, false);
|
||||
} else {
|
||||
updateRepresentation(values, false, false);
|
||||
setRepresentationSubmit(true);
|
||||
}
|
||||
const submitTransition = resolveSubmitTransition({
|
||||
"representationType": repType,
|
||||
"showQuestionnaireSection": showQuestionnaireSection,
|
||||
"questionnaireCount": questionnaireCount
|
||||
});
|
||||
|
||||
if (submitTransition === "advanceQuestionnaire") {
|
||||
setShowQuestionnaireSection(
|
||||
getQuestionnaireNextSection(
|
||||
showQuestionnaireSection,
|
||||
questionnaireCount
|
||||
)
|
||||
);
|
||||
updateRepresentation(values, false, false);
|
||||
} else {
|
||||
updateRepresentation(values, false, false);
|
||||
setRepresentationSubmit(true);
|
||||
@@ -1252,7 +1259,7 @@ let MakeRepresentation = (props) => {
|
||||
return (
|
||||
<div>
|
||||
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
||||
{currentView.representationSubmit ? (
|
||||
{showCheckStage ? (
|
||||
<RepCompleteSubmit
|
||||
formObj={formObj}
|
||||
capacityOptionsArr={capacityOptionsArr}
|
||||
|
||||
Reference in New Issue
Block a user