Merged PR 2241: refactor(newappeal): simplify start flow readability (Slice 8)

refactor(newappeal): simplify start flow readability (Slice 8)

Related work items: #22590
This commit is contained in:
Robert Bond
2026-04-13 12:55:58 +00:00
parent ffcccf8981
commit f3a05db323
3 changed files with 32 additions and 25 deletions
+19 -16
View File
@@ -262,7 +262,7 @@ const RenderRadio = ({
{
["documentCheckList_" +
id]:
custom.requiredDocumentLabel,
custom.requiredDocumentLabel
}
))
: delete docListObj[
@@ -297,7 +297,7 @@ function Radiofield(props) {
formProps,
parentFieldShowOnValue,
validation,
hint,
hint
} = props;
const router = useRouter();
@@ -438,22 +438,25 @@ let AboutYou = (props) => {
const router = useRouter();
const { locale } = router;
const isWelsh = router.locale == "cy";
const {
onSubmit,
handleSubmit,
appellantAgentValue,
setFormStep,
updateField,
updateField
} = props;
const [isAgent, setIsAgent] = useState(false);
const isAgentSelected = appellantAgentValue == "846040001";
const isAppellantSelected = appellantAgentValue == "846040000";
const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"];
const appellantAgent =
router.locale == "cy" ? ["Apelydd", "Asiant"] : ["Appellant", "Agent"];
const contactPref =
router.locale == "cy" ? ["Ebost", "Post"] : ["Email", "Post"];
const yesNo = isWelsh ? ["Ydw", "Na"] : ["Yes", "No"];
const appellantAgent = isWelsh
? ["Apelydd", "Asiant"]
: ["Appellant", "Agent"];
const contactPref = isWelsh ? ["Ebost", "Post"] : ["Email", "Post"];
const required = (value) =>
value ? undefined : t("newappeal:is-required-label");
@@ -493,7 +496,7 @@ let AboutYou = (props) => {
};
const handlePartialUpdate = () => {
if (appellantAgentValue == "846040001" && isAgent == false) {
if (isAgentSelected && isAgent == false) {
updateField("caseForm", "pinswg_appellantfirstname", "");
updateField("caseForm", "pinswg_appellantlastname", "");
updateField("caseForm", "pinswg_appellantemailaddress", "");
@@ -570,7 +573,7 @@ let AboutYou = (props) => {
errorMsg={t("newappeal:select-an-option-label")}
hint={t("newappeal:about-you-who-are-you-hint-label")}
/>
{appellantAgentValue == "846040000" && (
{isAppellantSelected && (
<>
<h2 className="govuk-heading-s">
{t("newappeal:about-you-appellant-contact-details")}
@@ -668,7 +671,7 @@ let AboutYou = (props) => {
/>
</>
)}
{appellantAgentValue == "846040001" && (
{isAgentSelected && (
<>
<h2 className="govuk-heading-s">
{t("newappeal:about-you-appellant-contact-details")}
@@ -891,15 +894,15 @@ const mapStateToProps = (state) => {
pinswg_appellantaddress:
state.accountDetails.accountDetails.address1_composite,
pinswg_appellantphonenumber:
state.accountDetails.accountDetails.telephone1,
},
state.accountDetails.accountDetails.telephone1
}
};
};
const mapDispatchToProps = (dispatch) => {
return {
updateField: (form, field, newValue) =>
dispatch(change(form, field, newValue)),
dispatch(change(form, field, newValue))
};
};
@@ -915,7 +918,7 @@ AboutYou = connect((state) => {
const appellantAgentValue = selector(state, "pinswg_appellantagent");
return {
appellantAgentValue,
appellantAgentValue
};
})(AboutYou);
@@ -928,6 +931,6 @@ export default connect(
reduxForm({
form: "caseForm",
enableReinitialize: true, // this is needed!!
destroyOnUnmount: false,
destroyOnUnmount: false
})(AboutYou)
);
+12 -8
View File
@@ -378,6 +378,7 @@ let CreateCase = (props) => {
const router = useRouter();
const { locale } = router;
const isWelsh = router.locale == "cy";
const { LPAData, onSubmit, handleSubmit, formData } = props;
@@ -399,16 +400,17 @@ let CreateCase = (props) => {
event.preventDefault();
var appTypeCollection = values.appealTypes;
const selectedAppealType = values.appealTypes;
const confirmHASCAS = values.confirmHASCAS;
formStep == 0 && setFormStep(1);
whichAppealType =
values.appealTypes == "846040004" && values.confirmHASCAS == "true"
selectedAppealType == "846040004" && confirmHASCAS == "true"
? "846040004"
: values.appealTypes == "846040004" &&
values.confirmHASCAS == "false"
: selectedAppealType == "846040004" && confirmHASCAS == "false"
? "846040000"
: values.appealTypes;
: selectedAppealType;
var whichAppealType = whichAppealType;
@@ -435,15 +437,17 @@ let CreateCase = (props) => {
// values,
// props.containerID
// )
const selectedLpaName = props.LPAData.LPAData.value.filter((obj) => {
return obj.accountid === values.lpaTypes;
})[0].name;
createNewCaseBlob(
appTypeCollection.appealTypeID,
values.lpaTypes,
props.loggedInUser,
values,
props.containerID,
props.LPAData.LPAData.value.filter((obj) => {
return obj.accountid === values.lpaTypes;
})[0].name
selectedLpaName
)
.then((data) => {
router.replace(
@@ -477,7 +481,7 @@ let CreateCase = (props) => {
// }
// );
};
const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"];
const yesNo = isWelsh ? ["Ydw", "Na"] : ["Yes", "No"];
var parentField = "appealTypes",
formProps = props.whichForm,
+1 -1
View File
@@ -74,7 +74,7 @@ Status: COMPLETE
### Slice 8 — Start Flow Cleanup (CreateCase / AboutYou)
Status: NOT STARTED
Status: COMPLETE
---