Merged PR 2242: Refactor: New Appeal flow structural cleanup (Slices 1–8, no behaviour change)

## Summary

This PR merges the completed new-appeal refactor stream (Slices 1–8) into SIPS-Development.

This refactor was executed in controlled slices with regression validation at each step.

## Scope

Structural and readability improvements only:
- XML/form derivation extraction
- payload and file helper extraction
- side-effect facade introduction
- BuildSection and BuildCheckSection decomposition
- BuildCheckRow formatter map refactor
- nested prop boundary cleanup
- start-flow cleanup (CreateCase / AboutYou)

## Behaviour

No intended behavioural changes.

The following were explicitly preserved:
- S78 journey behaviour
- payload shapes and field names/ids
- HASCAS mapping logic
- appellant/agent branching
- validation rules and messages
- redirect/query parameters (`lpa`, `apt`, `id`)
- navigation and side-effect sequencing
- EN/CY output parity

## Validation

Full regression has been performed on:
- start flow (CreateCase / AboutYou)
- save and resume flows
- file upload handling
- check answers rendering
- submit/finalisation sequence
- confirmation flow
- CRM insertion path
- EN/CY parity

Additional checks:
- docsOffline branch behaviour
- completion and partial-save email paths
- negative-path validation scenarios
- lint (warnings baseline unchanged)

## Risk

Low:
- changes are structural only
- no business logic changes
- no contract changes

## Rollback

Safe rollback via reverting this merge commit.

## Notes

This refactor reduces coupling and prepares the new-appeal flow for future appeal-type expansion.

Related work items: #22570, #22576, #22577, #22583, #22586, #22587, #22588, #22590
This commit is contained in:
Robert Bond
2026-04-13 13:09:12 +00:00
parent bd3d311cfb
commit 0de9268255
47 changed files with 2010 additions and 945 deletions
+21 -14
View File
@@ -4,14 +4,19 @@ import { useRouter } from "next/router";
import { useEffect } from "react";
import { connect } from "react-redux";
import { formValueSelector } from "redux-form";
import { sendEmail } from "../../actions/services/notifyService";
import { sendCompletionEmailEffect } from "../../lib/newappeal/journeyEffects";
import { normalizeYesNoBooleans } from "../../lib/newappeal/payloadCleanup";
import { setCurrentSection } from "../../store/appealType/action";
import { getFormCollectionByID } from "../utils";
let CompleteAppeal = (props) => {
const legacyProps = props.props;
const legacyFormState = legacyProps.form;
const legacyAccountDetails = legacyProps.accountDetails;
useEffect(() => {
let incidentId = props.appealType.caseReference.incidentid;
let updateBody = props.props.form.appealForm.values;
let updateBody = legacyFormState.appealForm.values;
let appTypeCollection = getFormCollectionByID(
props.appealType.appealTypeID
@@ -23,7 +28,7 @@ let CompleteAppeal = (props) => {
Object.assign(updateBody, {
"pinswg_Appellant@odata.bind":
"/contacts(" + props.props.accountDetails.loggedinUserId + ")",
"/contacts(" + legacyAccountDetails.loggedinUserId + ")",
"pinswg_LocalPlanningAuthority@odata.bind":
"/accounts(" + props.appealType.appealLPA + ")",
"pinswg_name": props.appealType.caseReference.ticketnumber,
@@ -31,10 +36,7 @@ let CompleteAppeal = (props) => {
"/incidents(" + incidentId + ")"
});
updateBody = JSON.stringify(updateBody);
updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
updateBody = updateBody.replace(/:"No"/gm, `:false`);
updateBody = JSON.parse(updateBody);
updateBody = normalizeYesNoBooleans(updateBody);
let updateFormCollection = appTypeCollection.LogicalCollectionName;
let primaryAttribute = appTypeCollection.PrimaryIdAttribute;
@@ -46,13 +48,18 @@ let CompleteAppeal = (props) => {
: "618e0463-b092-4733-a024-bf8a3bbde808";
const reference = "PEDW-COMPLETE" + isWelsh && "-CY";
const emailAddress = props.props.accountDetails.loggedinUserEmail;
const emailAddress = legacyAccountDetails.loggedinUserEmail;
const personalisation = {
"caseReference": props.appealType.caseReference.ticketnumber,
"emailAddress": props.props.accountDetails.loggedinUserEmail,
"emailAddress": legacyAccountDetails.loggedinUserEmail,
"linkExpiry": 10 * 60
};
sendEmail(templateId, emailAddress, personalisation, reference);
sendCompletionEmailEffect(
templateId,
emailAddress,
personalisation,
reference
);
// sendCaseCompleteMessage(
// props.props.accountDetails.containerID,
@@ -65,12 +72,12 @@ let CompleteAppeal = (props) => {
window.scrollTo({ top: 0, behavior: "smooth" });
}, [
props.appealType.caseReference,
props.props.form.appealForm.values,
legacyFormState.appealForm.values,
props.appealType.appealLPA,
props.props.accountDetails.loggedinUserId,
legacyAccountDetails.loggedinUserId,
props.appealType.appealTypeID,
props.props.accountDetails.loggedinUserEmail,
props.props.accountDetails.containerID
legacyAccountDetails.loggedinUserEmail,
legacyAccountDetails.containerID
]);
let { t } = useTranslation();