## 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
198 lines
7.9 KiB
JavaScript
198 lines
7.9 KiB
JavaScript
import _ from "lodash";
|
|
import useTranslation from "next-translate/useTranslation";
|
|
import { useRouter } from "next/router";
|
|
import BuildField from "./buildfield";
|
|
import {
|
|
parseRowOuterHTML,
|
|
selectRowDataFieldContent,
|
|
selectRowDataFieldName,
|
|
selectRowDateEnd,
|
|
selectRowDateStart,
|
|
selectRowDocumentTypeCode,
|
|
selectRowFieldType,
|
|
selectRowHint,
|
|
selectRowLabelDescriptions,
|
|
selectRowMaxFieldLength,
|
|
selectRowMaxSubField,
|
|
selectRowParentField,
|
|
selectRowParentFieldShowOnValue,
|
|
selectRowRequiredDocumentLabel,
|
|
selectRowRequiredDocumentValue,
|
|
selectRowValidation
|
|
} from "../../lib/newappeal/formDerivation";
|
|
|
|
export default function BuildRow(props) {
|
|
let { t } = useTranslation();
|
|
const legacyProps = props.props;
|
|
const legacyPageProps = legacyProps.props;
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
|
|
const {
|
|
rowXML,
|
|
whichSection,
|
|
sectionCount,
|
|
onSubmit,
|
|
mandatoryFieldsData,
|
|
setUploadCount,
|
|
uploadCount,
|
|
setFileCount,
|
|
completedUploadFilesCount,
|
|
setCompletedUploadFilesCount
|
|
} = props;
|
|
|
|
return (
|
|
<div className="govuk-grid-column-full">
|
|
{Object.keys(rowXML).map((key, index) => {
|
|
var doc = parseRowOuterHTML(rowXML[key].outerHTML);
|
|
if (_.isEmpty(rowXML[key].innerHTML)) {
|
|
("");
|
|
} else {
|
|
var rows = selectRowLabelDescriptions(doc);
|
|
var fieldtype = selectRowFieldType(doc);
|
|
var validation = selectRowValidation(doc);
|
|
var maxFieldLength = selectRowMaxFieldLength(doc);
|
|
var maxSubField = selectRowMaxSubField(doc);
|
|
var datafieldname = selectRowDataFieldName(doc);
|
|
var datafieldcontent = selectRowDataFieldContent(doc);
|
|
var parentField = selectRowParentField(doc);
|
|
|
|
var parentFieldShowOnValue =
|
|
selectRowParentFieldShowOnValue(doc);
|
|
|
|
var requiredDocumentValue =
|
|
selectRowRequiredDocumentValue(doc);
|
|
|
|
var requiredDocumentLabel =
|
|
selectRowRequiredDocumentLabel(doc);
|
|
|
|
var documentTypeCode = selectRowDocumentTypeCode(doc);
|
|
|
|
var hint = selectRowHint(doc);
|
|
var dateStart = selectRowDateStart(doc);
|
|
var dateEnd = selectRowDateEnd(doc);
|
|
|
|
hint = !_.isEmpty(hint) && hint[0].value;
|
|
|
|
validation = !_.isEmpty(validation)
|
|
? validation[0].value
|
|
: [];
|
|
|
|
maxFieldLength =
|
|
!_.isEmpty(maxFieldLength) && maxFieldLength[0].value;
|
|
|
|
maxSubField =
|
|
!_.isEmpty(maxSubField) && maxSubField[0].value;
|
|
|
|
parentField =
|
|
!_.isEmpty(parentField) && parentField[0].value;
|
|
|
|
parentFieldShowOnValue =
|
|
!_.isEmpty(parentFieldShowOnValue) &&
|
|
parentFieldShowOnValue[0].value;
|
|
|
|
datafieldcontent =
|
|
!_.isEmpty(datafieldcontent) &&
|
|
datafieldcontent[0].value;
|
|
|
|
requiredDocumentValue =
|
|
!_.isEmpty(requiredDocumentValue) &&
|
|
requiredDocumentValue[0].value;
|
|
|
|
requiredDocumentLabel =
|
|
!_.isEmpty(requiredDocumentLabel) &&
|
|
requiredDocumentLabel[0].value;
|
|
|
|
documentTypeCode =
|
|
!_.isEmpty(documentTypeCode) &&
|
|
documentTypeCode[0].value;
|
|
|
|
dateStart = !_.isEmpty(dateStart) && dateStart[0].value;
|
|
|
|
dateEnd = !_.isEmpty(dateEnd) && dateEnd[0].value;
|
|
|
|
//const isRequiredField = jsonpath({path:
|
|
// "$..value[?(@ && @.LogicalName=='" +
|
|
// datafieldname[0].value +
|
|
// "')]",
|
|
// mandatoryFieldsData
|
|
// );
|
|
|
|
//console.log("build row datafieldname[0]", datafieldname[0]);
|
|
|
|
if (datafieldname[0].value == "pinswg_fileUpload") {
|
|
return (
|
|
<BuildField
|
|
fieldType={fieldtype[0].value}
|
|
label={rows[0].value}
|
|
datafieldname={datafieldname[0].value}
|
|
key={key}
|
|
props={props}
|
|
picklistData={
|
|
legacyPageProps.formData.pickListData
|
|
}
|
|
mandatoryFieldsData={mandatoryFieldsData}
|
|
documentTypeCode={documentTypeCode}
|
|
setFileCount={setFileCount}
|
|
setUploadCount={setUploadCount}
|
|
uploadCount={uploadCount}
|
|
/>
|
|
);
|
|
} else {
|
|
//console.log(
|
|
// datafieldname[0].value,
|
|
// isRequiredField[0].RequiredLevel.Value
|
|
// );
|
|
// if (typeof isRequiredField[0] != "undefined") {
|
|
// if (
|
|
// isRequiredField[0].RequiredLevel.Value != "None"
|
|
// ) {
|
|
//console.log(datafieldname[0].value, validation);
|
|
return (
|
|
<BuildField
|
|
fieldType={fieldtype[0].value}
|
|
label={rows[0].value}
|
|
datafieldname={datafieldname[0].value}
|
|
datafieldcontent={datafieldcontent}
|
|
parentField={parentField}
|
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
|
key={key}
|
|
props={props}
|
|
picklistData={
|
|
legacyPageProps.formData.pickListData
|
|
}
|
|
mandatoryFieldsData={mandatoryFieldsData}
|
|
hint={hint}
|
|
requiredDocumentLabel={requiredDocumentLabel}
|
|
requiredDocumentValue={requiredDocumentValue}
|
|
validation={validation}
|
|
maxFieldLength={maxFieldLength}
|
|
dateStart={dateStart}
|
|
dateEnd={dateEnd}
|
|
setDocumentsList={legacyProps.setDocumentsList}
|
|
documentList={
|
|
legacyProps.appealType.documentList
|
|
}
|
|
documentTypeCode={documentTypeCode}
|
|
setFilesForAppeal={
|
|
legacyProps.setFilesForAppeal
|
|
}
|
|
maxSubField={maxSubField}
|
|
setFileCount={setFileCount}
|
|
setUploadCount={setUploadCount}
|
|
/>
|
|
);
|
|
// } else {
|
|
// return null;
|
|
// }
|
|
// } else {
|
|
// return null;
|
|
// }
|
|
}
|
|
}
|
|
})}
|
|
</div>
|
|
);
|
|
}
|