From ffcccf8981af98773dd1687329441632642f3056 Mon Sep 17 00:00:00 2001 From: Robert Bond Date: Mon, 13 Apr 2026 12:25:45 +0000 Subject: [PATCH] Merged PR 2240: refactor(newappeal): simplify nested prop boundaries (Slice 7) refactor(newappeal): simplify nested prop boundaries (Slice 7) Related work items: #22588 --- components/newappeal/buildcheckrow.js | 88 ++++++++++++----------- components/newappeal/buildchecksection.js | 21 +++--- components/newappeal/buildfield.js | 2 +- components/newappeal/buildrow.js | 12 ++-- components/newappeal/buildsection.js | 31 ++++---- components/newappeal/complete.js | 20 +++--- context/refactor-tracker.md | 4 +- 7 files changed, 98 insertions(+), 80 deletions(-) diff --git a/components/newappeal/buildcheckrow.js b/components/newappeal/buildcheckrow.js index 946046d6..7925320f 100644 --- a/components/newappeal/buildcheckrow.js +++ b/components/newappeal/buildcheckrow.js @@ -27,6 +27,9 @@ import { let BuildCheckRow = (props) => { let { t } = useTranslation(); + const legacyProps = props.props; + const legacyFormState = legacyProps.form; + const legacyFormData = legacyProps.formData; const router = useRouter(); const { locale } = router; @@ -140,7 +143,7 @@ let BuildCheckRow = (props) => { // ) { const fieldTypeValue = fieldtype[0].value; const fieldValue = - props.props.form["appealForm"].values[ + legacyFormState["appealForm"].values[ datafieldname[0].value ]; @@ -190,7 +193,8 @@ let BuildCheckRow = (props) => { {getDocumentTypeFromFilename( blob.name ) === - documentTypeCode[0].value && ( + documentTypeCode[0] + .value && (
{ ); const renderTenantValue = () => - typeof fieldValue != "undefined" && fieldValue != null ? ( - fieldValue.map((tenant, index) => { - console.log( - typeof tenant.pinswg_owners_firstname - ); - return typeof tenant.pinswg_owners_firstname != - "undefined" || - typeof tenant.pinswg_agriculturaltenantname_firstname != - "undefined" ? ( -
-
- {tenant?.pinswg_agriculturaltenantname_firstname && - tenant.pinswg_agriculturaltenantname_firstname + - " " + - tenant.pinswg_agriculturaltenantname_lastname} + typeof fieldValue != "undefined" && fieldValue != null + ? fieldValue.map((tenant, index) => { + console.log( + typeof tenant.pinswg_owners_firstname + ); + return typeof tenant.pinswg_owners_firstname != + "undefined" || + typeof tenant.pinswg_agriculturaltenantname_firstname != + "undefined" ? ( +
+
+ {tenant?.pinswg_agriculturaltenantname_firstname && + tenant.pinswg_agriculturaltenantname_firstname + + " " + + tenant.pinswg_agriculturaltenantname_lastname} - {tenant?.pinswg_owners_firstname && - tenant.pinswg_owners_firstname + - " " + - tenant.pinswg_owners_lastname} -
-
- Served:{" "} - {formatDate(tenant.dateserved)} -
-
- ) : ( - "" - ); - }) - ) : ( - "N/A" - ); + {tenant?.pinswg_owners_firstname && + tenant.pinswg_owners_firstname + + " " + + tenant.pinswg_owners_lastname} +
+
+ Served:{" "} + {formatDate(tenant.dateserved)} +
+
+ ) : ( + "" + ); + }) + : "N/A"; const formatterMap = { "{E0DECE4B-6666-4a8f-A065-082708572369}": () => ( @@ -281,13 +283,13 @@ let BuildCheckRow = (props) => { formatDate(fieldValue), "{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}": () => getPickListLabel( - props.props.formData.pickListData, + legacyFormData.pickListData, datafieldname[0].value, fieldValue ), "{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}": () => getRadioLabel( - props.props.formData.pickListData, + legacyFormData.pickListData, datafieldname[0].value, fieldValue ), @@ -297,8 +299,8 @@ let BuildCheckRow = (props) => { ? "Nac ydw" : "No" : router.locale == "cy" - ? "Oes" - : "Yes", + ? "Oes" + : "Yes", "{16D63FD6-119B-4353-BDCA-18358721C3FE}": renderFileUploadValue, "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}": diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js index ea90fe51..a80c7439 100644 --- a/components/newappeal/buildchecksection.js +++ b/components/newappeal/buildchecksection.js @@ -55,6 +55,11 @@ let BuildCheckSection = (props) => { docsOffline } = props; + const legacyProps = props.props; + const legacyAppealType = legacyProps.appealType; + const legacyFormState = legacyProps.form; + const legacyAccountDetails = legacyProps.accountDetails; + const parser = new DOMParser(); var doc = parser.parseFromString(props.formXML, "text/xml"); var titles = xpath.select( @@ -89,7 +94,7 @@ let BuildCheckSection = (props) => { let buildAppealFilesArray = []; //console.log("attached docs: - ", buildAppealFilesArray); - buildAppealFilesArray = props.props.appealType.fileList?.value[0] || []; + buildAppealFilesArray = legacyAppealType.fileList?.value[0] || []; //let filesUploadObj = buildAppealFilesArray; // let filesUploadObj = props.appealType.fileList.hasOwnProperty("value") // ? props.appealType.fileList.value[0] @@ -113,13 +118,13 @@ let BuildCheckSection = (props) => { "name" ); - let pdfObj = props.props.form.appealForm.values; + let pdfObj = legacyFormState.appealForm.values; pdfObj = updateLinks(pdfObj); Object.assign(pdfObj, { "filesList": buildAppealFilesArray, - "containerID": props.props.accountDetails.containerID, + "containerID": legacyAccountDetails.containerID, "casefolderID": props.appealType.caseReference.ticketnumber }); @@ -162,7 +167,7 @@ let BuildCheckSection = (props) => { ? (setFinaliseAppealProcess(true), await generateAppealPDFEffect( pdfObj, - props.props.accountDetails.containerID, + legacyAccountDetails.containerID, props.appealType.caseReference.ticketnumber, router.query.appealtypes, pdfObj.filesList @@ -171,9 +176,9 @@ let BuildCheckSection = (props) => { .then((data) => { console.log("have generated pdf:", data); sendCaseCompleteMessageEffect( - props.props.accountDetails.containerID, + legacyAccountDetails.containerID, props.appealType.caseReference.ticketnumber, - props.props.accountDetails.accountDetails + legacyAccountDetails.accountDetails .pinswg_typeofinvolvement ); }) @@ -202,8 +207,8 @@ let BuildCheckSection = (props) => { const containerID = props.accountDetails?.containerID || - props.props?.accountDetails?.containerID || - props.props?.props?.accountDetails?.containerID; + legacyProps?.accountDetails?.containerID || + legacyProps?.props?.accountDetails?.containerID; const caseRef = props?.currentView?.caseReference?.ticketnumber || props?.appealType?.caseReference?.ticketnumber; diff --git a/components/newappeal/buildfield.js b/components/newappeal/buildfield.js index 892fec4d..ea7878f0 100644 --- a/components/newappeal/buildfield.js +++ b/components/newappeal/buildfield.js @@ -209,7 +209,7 @@ export default function BuildField(props) { uploadCount={uploadCount} setFileCount={setFileCount} setUploadCount={setUploadCount} - props={props?.props?.props?.props} + props={pageProps} />
), diff --git a/components/newappeal/buildrow.js b/components/newappeal/buildrow.js index cabca969..dd12e937 100644 --- a/components/newappeal/buildrow.js +++ b/components/newappeal/buildrow.js @@ -23,6 +23,8 @@ import { export default function BuildRow(props) { let { t } = useTranslation(); + const legacyProps = props.props; + const legacyPageProps = legacyProps.props; const router = useRouter(); const { locale } = router; @@ -128,7 +130,7 @@ export default function BuildRow(props) { key={key} props={props} picklistData={ - props.props.props.formData.pickListData + legacyPageProps.formData.pickListData } mandatoryFieldsData={mandatoryFieldsData} documentTypeCode={documentTypeCode} @@ -158,7 +160,7 @@ export default function BuildRow(props) { key={key} props={props} picklistData={ - props.props.props.formData.pickListData + legacyPageProps.formData.pickListData } mandatoryFieldsData={mandatoryFieldsData} hint={hint} @@ -168,13 +170,13 @@ export default function BuildRow(props) { maxFieldLength={maxFieldLength} dateStart={dateStart} dateEnd={dateEnd} - setDocumentsList={props.props.setDocumentsList} + setDocumentsList={legacyProps.setDocumentsList} documentList={ - props.props.appealType.documentList + legacyProps.appealType.documentList } documentTypeCode={documentTypeCode} setFilesForAppeal={ - props.props.setFilesForAppeal + legacyProps.setFilesForAppeal } maxSubField={maxSubField} setFileCount={setFileCount} diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js index 9b8ed214..d55e371e 100644 --- a/components/newappeal/buildsection.js +++ b/components/newappeal/buildsection.js @@ -72,6 +72,12 @@ let BuildSection = (props) => { mandatoryFieldsData } = props; + const legacyProps = props.props; + const legacyAccountDetails = legacyProps.accountDetails; + const legacyFormState = legacyProps.form; + const legacyAppealType = legacyProps.appealType; + const legacyUrl = legacyProps.url; + const documentListObj = props.appealType.documentList; const currentSection = props.appealType.currentSection; @@ -130,8 +136,8 @@ let BuildSection = (props) => { await uploadAppealFilesEffect( dataObj, fileListObj, - props.props.accountDetails.containerID, - props.props.appealType.caseReference.ticketnumber + legacyAccountDetails.containerID, + legacyAppealType.caseReference.ticketnumber ).then((data) => { //console.log("$1", data); setCompletedUploadFiles(true); @@ -223,7 +229,7 @@ let BuildSection = (props) => { Object.assign(updateBody, { "pinswg_appealcasetype": props.appealType.appealTypeID, "pinswg_Appellant@odata.bind": - "/contacts(" + props.props.accountDetails.loggedinUserId + ")", + "/contacts(" + legacyAccountDetails.loggedinUserId + ")", "pinswg_name": props.appealType.caseReference.ticketnumber, [updateBindAppealTypeToIncident + "@odata.bind"]: "/incidents(" + incidentId + ")" @@ -241,12 +247,12 @@ let BuildSection = (props) => { const reference = "PEDW-PARTIAL"; const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75"; const templateIdCY = "f3c4a56b-bfb8-4d39-97dd-888df3062b0a"; - 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, "returnLink": - props.props.url + + legacyUrl + (router.locale != "en" ? "/cy/fymhorth/" : "/myportal/") + appTypeCollection.UrlName + "?lpa=" + @@ -354,7 +360,7 @@ let BuildSection = (props) => { const [hasErrors, setHasErrors] = useState(""); const getErrors = () => { - let errorsobj = props.props.form["appealForm"]; + let errorsobj = legacyFormState["appealForm"]; //setHasErrors(errorsobj.hasOwnProperty("syncErrors")); window.scrollTo(0, 0); }; @@ -385,7 +391,7 @@ let BuildSection = (props) => { }; const hasUploadFiles = () => { - const formArr = props.props.form["appealForm"].values; + const formArr = legacyFormState["appealForm"].values; const prefix = "pinswg_fileUpload"; const hasFiles = Object.keys(formArr).some((key) => key.startsWith(prefix) @@ -431,11 +437,10 @@ let BuildSection = (props) => { onClick={() => { getErrors(); let valuesObj = _.has( - props.props.form[props.form], + legacyFormState[props.form], "values" ) - ? props.props.form[props.form] - .values + ? legacyFormState[props.form].values : {}; //console.log("valuesobj:", valuesObj); @@ -470,7 +475,7 @@ let BuildSection = (props) => { className="govuk-button progress-save " onClick={() => { let valuesObj = - props.props.form[props.form] + legacyFormState[props.form] .values || {}; // console.log( @@ -532,7 +537,7 @@ let BuildSection = (props) => { className="govuk-button progress-save " onClick={() => { let valuesObj = - props.props.form[props.form] + legacyFormState[props.form] .values || {}; // console.log( diff --git a/components/newappeal/complete.js b/components/newappeal/complete.js index 7acbbd83..a9f3d150 100644 --- a/components/newappeal/complete.js +++ b/components/newappeal/complete.js @@ -10,9 +10,13 @@ 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 @@ -24,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, @@ -44,10 +48,10 @@ 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 }; sendCompletionEmailEffect( @@ -68,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(); diff --git a/context/refactor-tracker.md b/context/refactor-tracker.md index 657d5fdb..312abc25 100644 --- a/context/refactor-tracker.md +++ b/context/refactor-tracker.md @@ -4,7 +4,7 @@ Base branch for this tracker: `refactor` ## Status -Current slice: Slice 7 — Props Boundary Cleanup +Current slice: Slice 8 — Start Flow Cleanup (CreateCase / AboutYou) Status: READY TO START --- @@ -68,7 +68,7 @@ Status: COMPLETE ### Slice 7 — Props Boundary Cleanup -Status: NOT STARTED +Status: COMPLETE ---