check form updates

This commit is contained in:
2022-06-07 14:36:47 +01:00
parent 3b61d651f6
commit 9d90b7f0a8
22 changed files with 356 additions and 133 deletions
+76 -9
View File
@@ -1,7 +1,8 @@
import useTranslation from "next-translate/useTranslation";
import { useRouter } from "next/router";
import { connect } from "react-redux";
import { Field, formValueSelector, reduxForm } from "redux-form";
import { useEffect } from "react";
import { Field, formValueSelector, reduxForm, change } from "redux-form";
import {
FieldsTranslations,
Radiofield,
@@ -15,7 +16,13 @@ let AboutYou = (props) => {
const router = useRouter();
const { locale } = router;
const { onSubmit, handleSubmit, appellantAgentValue, setFormStep } = props;
const {
onSubmit,
handleSubmit,
appellantAgentValue,
setFormStep,
updateField,
} = props;
const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"];
const appellantAgent =
@@ -243,7 +250,7 @@ let AboutYou = (props) => {
>
<fieldset
className="govuk-fieldset"
aria-describedby={name + "-hint"}
aria-describedby={datafieldname + "-hint"}
>
<legend className="govuk-fieldset__legend govuk-fieldset__legend--s govuk-!-font-weight-regular">
<label
@@ -272,11 +279,12 @@ let AboutYou = (props) => {
}
>
{" "}
{custom.hint != false && (
<div className="govuk-hint">
{t(custom.hint)}
</div>
)}
{custom.hint != false ||
(custom.hint != undefined && (
<div className="govuk-hint">
{t(custom.hint)}
</div>
))}
{Object.keys(options).map((key, index) => (
<div
className="govuk-radios__item"
@@ -424,6 +432,47 @@ let AboutYou = (props) => {
console.log(JSON.stringify(values));
setFormStep(1);
};
const handlePartialUpdate = () => {
if (appellantAgentValue == "846040001") {
updateField("caseForm", "pinswg_appellantfirstname", "");
updateField("caseForm", "pinswg_appellantlastname", "");
updateField("caseForm", "pinswg_appellantemailaddress", "");
updateField("caseForm", "pinswg_appellantaddress", "");
updateField("caseForm", "pinswg_appellantphonenumber", "");
} else {
updateField(
"caseForm",
"pinswg_appellantfirstname",
props.initialValues.pinswg_appellantfirstname
);
updateField(
"caseForm",
"pinswg_appellantlastname",
props.initialValues.pinswg_appellantlastname
);
updateField(
"caseForm",
"pinswg_appellantemailaddress",
props.initialValues.pinswg_appellantemailaddress
);
updateField(
"caseForm",
"pinswg_appellantaddress",
props.initialValues.pinswg_appellantaddress
);
updateField(
"caseForm",
"pinswg_appellantphonenumber",
props.initialValues.pinswg_appellantphonenumber
);
}
};
useEffect(() => {
handlePartialUpdate();
}, [appellantAgentValue]);
return (
<form onSubmit={handleSubmit(onHandleSubmit)}>
<Field
@@ -723,11 +772,27 @@ const mapStateToProps = (state) => {
formData: state.formData,
appealType: state.appealType,
//form: state.form,
initialValues: {
pinswg_appellantfirstname:
state.accountDetails.accountDetails.firstname,
pinswg_appellantlastname:
state.accountDetails.accountDetails.lastname,
pinswg_appellantemailaddress:
state.accountDetails.accountDetails.emailaddress1,
pinswg_appellantaddress:
state.accountDetails.accountDetails.address1_composite,
pinswg_appellantphonenumber:
state.accountDetails.accountDetails.telephone1,
},
};
};
const mapDispatchToProps = (dispatch) => {
return {};
return {
updateField: (form, field, newValue) =>
dispatch(change(form, field, newValue)),
};
};
// AboutYou = reduxForm({
@@ -754,6 +819,8 @@ export default connect(
)(
reduxForm({
form: "caseForm",
enableReinitialize: true, // this is needed!!
destroyOnUnmount: false,
})(AboutYou)
);
+3
View File
@@ -36,6 +36,9 @@ export default function BuildField(props) {
case "{67FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}":
return <>{fieldValue}</>;
break;
case "{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}":
return <>{fieldValue}</>;
break;
case "{ 4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
return <>{fieldValue}</>;
break;
+83 -53
View File
@@ -9,6 +9,7 @@ import fieldLookup from "../../data/crmfieldlookuptranslations.json";
import {
getFormCollectionByID,
getPickListLabel,
getRadioLabel,
} from "../../components/utils";
import {
@@ -93,62 +94,91 @@ let BuildCheckRow = (props) => {
datafieldname[0].value +
"')]"
);
if (typeof isRequiredField[0] != "undefined") {
if (isRequiredField[0].RequiredLevel.Value != "None") {
return (
<div
className="govuk-summary-list__row"
key={key}
>
<dt className="govuk-summary-list__key">
{FieldsTranslations(rows[0].value)}
</dt>
<dd className="govuk-summary-list__value">
{fieldtype[0].value ==
"{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}"
? formatDate(
props.props.form["appealForm"]
if (
typeof props.props.form["appealForm"].values[
datafieldname[0].value
] != "undefined"
) {
if (typeof isRequiredField[0] != "undefined") {
if (
isRequiredField[0].RequiredLevel.Value != "None"
) {
return (
<div
className="govuk-summary-list__row"
key={key}
>
<dt className="govuk-summary-list__key">
{FieldsTranslations(rows[0].value)}
</dt>
<dd className="govuk-summary-list__value">
{fieldtype[0].value ==
"{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}"
? formatDate(
props.props.form[
"appealForm"
].values[
datafieldname[0].value
]
)
: fieldtype[0].value ==
"{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}"
? getPickListLabel(
props.props.formData
.pickListData,
datafieldname[0].value,
props.props.form[
"appealForm"
].values[
datafieldname[0].value
]
)
: fieldtype[0].value ==
"{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}"
? getRadioLabel(
props.props.formData
.pickListData,
datafieldname[0].value,
props.props.form[
"appealForm"
].values[
datafieldname[0].value
]
)
: props.props.form["appealForm"]
.values[
datafieldname[0].value
]
)
: fieldtype[0].value ==
"{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}"
? getPickListLabel(
props.props.formData
.pickListData,
datafieldname[0].value,
props.props.form["appealForm"]
.values[
datafieldname[0].value
]
)
: props.props.form["appealForm"]
.values[
datafieldname[0].value
]}
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
updateCurrentSection(
whichSection
);
}}
>
{t("newappeal:change-link-label")}
<span className="govuk-visually-hidden">
{" "}
{FieldsTranslations(
rows[0].value
]}
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
updateCurrentSection(
whichSection
);
}}
>
{t(
"newappeal:change-link-label"
)}
</span>
</a>
</dd>
</div>
);
<span className="govuk-visually-hidden">
{" "}
{FieldsTranslations(
rows[0].value
)}
</span>
</a>
</dd>
</div>
);
} else {
return null;
}
} else {
return null;
}
+3 -3
View File
@@ -65,9 +65,9 @@ let BuildCheckSection = (props) => {
<dl className="govuk-summary-list ">
{Object.keys(titles).map((key) => (
<div key={key}>
{/* <h2 className="govuk-heading-m">
{titles[key].value}
</h2> */}
<h2 className="govuk-heading-m govuk-!-margin-top-9">
{titles[key].value}
</h2>
<BuildCheckRow
formXML={formXML}
+6 -4
View File
@@ -164,10 +164,12 @@ export default function BuildField(props) {
break;
case "{16D63FD6-119B-4353-BDCA-18358721C3FE}":
return (
<FileUploadField
name={props.datafieldname}
label={props.label}
/>
<div className="govuk-!-margin-bottom-9">
<FileUploadField
name={props.datafieldname}
label={props.label}
/>
</div>
);
break;
+3 -3
View File
@@ -199,15 +199,15 @@ const BuildProgress = (props) => {
aria-labelledby="progress-list"
className="at-nav"
>
<h3 className="govuk-heading-s govuk-!-font-weight-bold gov-font-dark-grey progress-heading">
<h2 className="govuk-heading-s govuk-!-font-weight-bold gov-font-dark-grey progress-heading">
{t("newappeal:new-appeal-progress-nav-label")}:{" "}
<span className="progress-case-reference">
{props.props.appealType.caseReference.ticketnumber}
</span>
</h3>
</h2>
<hr className="govuk-section-break govuk-section-break--m govuk-section-break--visible" />
<ol className="govuk-list">
<ol className="govuk-list" id="progress-list">
<ul className="govuk-list ">
<li className="at-nav__page">
<ol className="govuk-list">
+5 -5
View File
@@ -193,7 +193,7 @@ let BuildSection = (props) => {
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<h1 className="govuk-heading-m govuk-!-margin-top-5">
{titles[0].value}
{FieldsTranslations(titles[0].value)}
</h1>
<form onSubmit={handleSubmit(onHandleSubmit)}>
{hasErrors == true ? (
@@ -222,7 +222,7 @@ let BuildSection = (props) => {
data-module="govuk-button"
onClick={() => getErrors()}
>
Continue
{t("common:continue-button")}
</button>
) : (
""
@@ -233,7 +233,7 @@ let BuildSection = (props) => {
className="govuk-button"
data-module="govuk-button"
>
Submit
{t("common:submit-button")}
</button>
) : (
""
@@ -246,7 +246,7 @@ let BuildSection = (props) => {
setCurrentSection(currentSection - 1)
}
>
Back
{t("common:back-link")}
</a>
) : (
""
@@ -372,7 +372,7 @@ let BuildSection = (props) => {
);
}}
>
Save and exit
{t("common:save-exit-button")}
</button>
</div>
</div>
-2
View File
@@ -35,8 +35,6 @@ let CompleteAppeal = (props) => {
});
updateBody = JSON.stringify(updateBody);
console.log("werwe");
updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
updateBody = updateBody.replace(/:"No"/gm, `:false`);
updateBody = JSON.parse(updateBody);
+1 -1
View File
@@ -121,7 +121,7 @@ function DropzoneComponent(props) {
);
return (
<div className="govuk-grid-row">
<div className="govuk-grid-row ">
<div className="govuk-form-group"></div>
<section className="container">
<div {...getRootProps({ style, className: "dropzone" })}>