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