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 RepLandOwner from "./representationLandowner";
|
||||||
import RepresentationProgress_enforcement from "./representationProgress/representationProgress_enforcement";
|
import RepresentationProgress_enforcement from "./representationProgress/representationProgress_enforcement";
|
||||||
import RepresentationProgress_s78 from "./representationProgress/representationProgress_s78";
|
import RepresentationProgress_s78 from "./representationProgress/representationProgress_s78";
|
||||||
|
import {
|
||||||
|
getQuestionnaireNextSection,
|
||||||
|
resolveJourneyStageFlags,
|
||||||
|
resolveRepresentationControlKey,
|
||||||
|
resolveSubmitTransition
|
||||||
|
} from "./utils/stepResolution";
|
||||||
|
|
||||||
let MakeRepresentation = (props) => {
|
let MakeRepresentation = (props) => {
|
||||||
let { t } = useTranslation();
|
let { t } = useTranslation();
|
||||||
@@ -105,6 +111,11 @@ let MakeRepresentation = (props) => {
|
|||||||
: false;
|
: false;
|
||||||
|
|
||||||
const isNRW = currentView.caseReference?.isNRW;
|
const isNRW = currentView.caseReference?.isNRW;
|
||||||
|
const { showCheckStage } = resolveJourneyStageFlags({
|
||||||
|
"representationSubmit": currentView.representationSubmit,
|
||||||
|
"representationSubmitConfirmation":
|
||||||
|
currentView.representationSubmitConfirmation
|
||||||
|
});
|
||||||
|
|
||||||
const setRepFileName = (values) => {
|
const setRepFileName = (values) => {
|
||||||
if (
|
if (
|
||||||
@@ -586,19 +597,16 @@ let MakeRepresentation = (props) => {
|
|||||||
setCurrentReference
|
setCurrentReference
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNormalizedCapacity = () => {
|
const { controlKey } = resolveRepresentationControlKey({
|
||||||
const rawCapacity =
|
"isLPA": isLPA,
|
||||||
currentView.representationCapacity ||
|
"representationCapacity": currentView.representationCapacity,
|
||||||
currentView.caseReference?.repDetails?.representationCapacity ||
|
"repDetailsCapacity":
|
||||||
"false";
|
currentView.caseReference?.repDetails?.representationCapacity,
|
||||||
return rawCapacity.toLowerCase();
|
"appealType": appealType,
|
||||||
};
|
"normalizeCapacity": normalizeCapacity
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (controlKey === "lpa-capacity-selection") {
|
||||||
isLPA &&
|
|
||||||
(!currentView.representationCapacity ||
|
|
||||||
currentView.representationCapacity === "")
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<RepLPACapacitySelection
|
<RepLPACapacitySelection
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
@@ -616,10 +624,8 @@ let MakeRepresentation = (props) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const capacity = normalizeCapacity(getNormalizedCapacity());
|
switch (controlKey) {
|
||||||
|
case "capacity-appellant": {
|
||||||
switch (capacity) {
|
|
||||||
case "appellant": {
|
|
||||||
const Component =
|
const Component =
|
||||||
appealType === 846040002
|
appealType === 846040002
|
||||||
? ConsultationAppellant
|
? ConsultationAppellant
|
||||||
@@ -634,7 +640,7 @@ let MakeRepresentation = (props) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "lpa": {
|
case "capacity-lpa": {
|
||||||
return (
|
return (
|
||||||
<RepLPA
|
<RepLPA
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
@@ -650,7 +656,7 @@ let MakeRepresentation = (props) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "agent": {
|
case "capacity-agent": {
|
||||||
const Component =
|
const Component =
|
||||||
appealType === 846040002 ? ConsultationAgent : RepAgent;
|
appealType === 846040002 ? ConsultationAgent : RepAgent;
|
||||||
return (
|
return (
|
||||||
@@ -663,7 +669,7 @@ let MakeRepresentation = (props) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "interestedparty": {
|
case "capacity-interestedparty": {
|
||||||
const Component =
|
const Component =
|
||||||
appealType === 846040002
|
appealType === 846040002
|
||||||
? ConsultationInterestedPartyPerson
|
? ConsultationInterestedPartyPerson
|
||||||
@@ -678,7 +684,7 @@ let MakeRepresentation = (props) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "landowner": {
|
case "capacity-landowner": {
|
||||||
return (
|
return (
|
||||||
<RepLandOwner
|
<RepLandOwner
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
@@ -1078,19 +1084,20 @@ let MakeRepresentation = (props) => {
|
|||||||
: normalizeCapacity(values.representationCapacity);
|
: normalizeCapacity(values.representationCapacity);
|
||||||
setRepresentationCapacity(capacity);
|
setRepresentationCapacity(capacity);
|
||||||
} else {
|
} else {
|
||||||
if (repType === "Questionnaire") {
|
const submitTransition = resolveSubmitTransition({
|
||||||
if (
|
"representationType": repType,
|
||||||
questionnaireCount !== 0 &&
|
"showQuestionnaireSection": showQuestionnaireSection,
|
||||||
showQuestionnaireSection < questionnaireCount
|
"questionnaireCount": questionnaireCount
|
||||||
) {
|
});
|
||||||
setShowQuestionnaireSection(
|
|
||||||
showQuestionnaireSection + 1
|
if (submitTransition === "advanceQuestionnaire") {
|
||||||
);
|
setShowQuestionnaireSection(
|
||||||
updateRepresentation(values, false, false);
|
getQuestionnaireNextSection(
|
||||||
} else {
|
showQuestionnaireSection,
|
||||||
updateRepresentation(values, false, false);
|
questionnaireCount
|
||||||
setRepresentationSubmit(true);
|
)
|
||||||
}
|
);
|
||||||
|
updateRepresentation(values, false, false);
|
||||||
} else {
|
} else {
|
||||||
updateRepresentation(values, false, false);
|
updateRepresentation(values, false, false);
|
||||||
setRepresentationSubmit(true);
|
setRepresentationSubmit(true);
|
||||||
@@ -1252,7 +1259,7 @@ let MakeRepresentation = (props) => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
||||||
{currentView.representationSubmit ? (
|
{showCheckStage ? (
|
||||||
<RepCompleteSubmit
|
<RepCompleteSubmit
|
||||||
formObj={formObj}
|
formObj={formObj}
|
||||||
capacityOptionsArr={capacityOptionsArr}
|
capacityOptionsArr={capacityOptionsArr}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
export const resolveJourneyStageFlags = ({
|
||||||
|
representationSubmit,
|
||||||
|
representationSubmitConfirmation
|
||||||
|
}) => {
|
||||||
|
const showCheckStage =
|
||||||
|
representationSubmit === true || representationSubmit === "true";
|
||||||
|
const showCompletionStage =
|
||||||
|
representationSubmitConfirmation === true ||
|
||||||
|
representationSubmitConfirmation === "true";
|
||||||
|
|
||||||
|
return {
|
||||||
|
showFormStage: !showCheckStage,
|
||||||
|
showCheckStage,
|
||||||
|
showCompletionStage
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resolveRepresentationControlKey = ({
|
||||||
|
isLPA,
|
||||||
|
representationCapacity,
|
||||||
|
repDetailsCapacity,
|
||||||
|
appealType,
|
||||||
|
normalizeCapacity
|
||||||
|
}) => {
|
||||||
|
if (isLPA && (!representationCapacity || representationCapacity === "")) {
|
||||||
|
return {
|
||||||
|
controlKey: "lpa-capacity-selection",
|
||||||
|
normalizedCapacity: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const rawCapacity = representationCapacity || repDetailsCapacity || "false";
|
||||||
|
const normalizedCapacity = normalizeCapacity(rawCapacity.toLowerCase());
|
||||||
|
|
||||||
|
return {
|
||||||
|
controlKey: `capacity-${normalizedCapacity}`,
|
||||||
|
normalizedCapacity
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resolveSubmitTransition = ({
|
||||||
|
representationType,
|
||||||
|
showQuestionnaireSection,
|
||||||
|
questionnaireCount
|
||||||
|
}) => {
|
||||||
|
if (representationType !== "Questionnaire") {
|
||||||
|
return "goToCheck";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
questionnaireCount !== 0 &&
|
||||||
|
showQuestionnaireSection < questionnaireCount
|
||||||
|
) {
|
||||||
|
return "advanceQuestionnaire";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "goToCheck";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getQuestionnaireNextSection = (
|
||||||
|
currentSection,
|
||||||
|
questionnaireCount
|
||||||
|
) => {
|
||||||
|
if (questionnaireCount !== 0 && currentSection < questionnaireCount) {
|
||||||
|
return currentSection + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentSection;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getQuestionnairePreviousSection = (currentSection) => {
|
||||||
|
return currentSection > 1 ? currentSection - 1 : currentSection;
|
||||||
|
};
|
||||||
@@ -6,8 +6,8 @@ Base branch: `refactor`
|
|||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
Current slice: Slice R2 — Representation Page Loader Separation
|
Current slice: Slice R3 — Journey Step Resolution Extraction
|
||||||
Status: COMPLETE
|
Status: IMPLEMENTED (manual validation pending)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -94,6 +94,30 @@ Isolate step navigation logic.
|
|||||||
- next/previous step logic
|
- next/previous step logic
|
||||||
- validation gating between steps
|
- validation gating between steps
|
||||||
|
|
||||||
|
**Completion notes (this slice):**
|
||||||
|
|
||||||
|
- Added pure step-resolution helpers in `components/case/representation/utils/stepResolution.js`:
|
||||||
|
- `resolveJourneyStageFlags({ representationSubmit, representationSubmitConfirmation })`
|
||||||
|
- `resolveRepresentationControlKey({ isLPA, representationCapacity, repDetailsCapacity, appealType, normalizeCapacity })`
|
||||||
|
- `resolveSubmitTransition({ representationType, showQuestionnaireSection, questionnaireCount })`
|
||||||
|
- `getQuestionnaireNextSection(currentSection, questionnaireCount)`
|
||||||
|
- `getQuestionnairePreviousSection(currentSection)`
|
||||||
|
- Updated `components/case/representation/index.js` to call helpers for:
|
||||||
|
- check-stage flag resolution (`showCheckStage`)
|
||||||
|
- control key resolution in `whichControl()`
|
||||||
|
- questionnaire/non-questionnaire submit transition decision
|
||||||
|
- questionnaire next-section increment calculation
|
||||||
|
- Preserved behaviour-critical constraints:
|
||||||
|
- no JSX structure redesign
|
||||||
|
- no route/query changes
|
||||||
|
- no payload/Redux shape changes
|
||||||
|
- no dispatch/API side-effect sequencing changes
|
||||||
|
- no representation-type availability logic changes (`buildRepsArr` unchanged)
|
||||||
|
- Validation evidence:
|
||||||
|
- `npm run lint` completed (warnings only, no new errors).
|
||||||
|
- `npm run test:reps` re-run completed: **6 passed**.
|
||||||
|
- Manual APP/IP/Agent/LPA and EN/CY checks: **pending for this slice**.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Slice R4 — Flow Shell Decomposition
|
### Slice R4 — Flow Shell Decomposition
|
||||||
|
|||||||
Reference in New Issue
Block a user