diff --git a/src/Components/HouseholdDataBlock/HouseholdDataBlock.js b/src/Components/HouseholdDataBlock/HouseholdDataBlock.js index 9d3c4d43d..a2e35feb4 100644 --- a/src/Components/HouseholdDataBlock/HouseholdDataBlock.js +++ b/src/Components/HouseholdDataBlock/HouseholdDataBlock.js @@ -13,7 +13,6 @@ import { householdMemberAgeHasError, displayHouseholdMemberAgeHelperText, personDataIsValid, - useErrorController, selectHasError, relationTypeHelperText, } from '../../Assets/validationFunctions.tsx'; @@ -36,7 +35,7 @@ const HouseholdDataBlock = ({ handleHouseholdDataSubmit }) => { const setPage = (page) => { navigate(`/${uuid}/step-${step}/${page}`); }; - const ageErrorController = useErrorController(householdMemberAgeHasError, displayHouseholdMemberAgeHelperText); + const [submittedCount, setSubmittedCount] = useState(0); const initialHouseholdData = formData.householdData[page - 1] ?? { age: '', @@ -118,7 +117,7 @@ const HouseholdDataBlock = ({ handleHouseholdDataSubmit }) => { defaultMessage="How old are you?" /> - {createTextField(ageTextfieldProps, ageErrorController)} + {createTextField(ageTextfieldProps, submittedCount)}

); @@ -134,18 +133,18 @@ const HouseholdDataBlock = ({ handleHouseholdDataSubmit }) => { defaultMessage="If your child is less than a year old, enter 0." />

- {createTextField(ageTextfieldProps, ageErrorController)} + {createTextField(ageTextfieldProps, submittedCount)}

); } }; - const createTextField = (componentInputProps, errorController) => { + const createTextField = (componentInputProps, submittedCount) => { return ( @@ -302,7 +301,7 @@ const HouseholdDataBlock = ({ handleHouseholdDataSubmit }) => { options={relationshipOptions} setHouseholdData={setHouseholdData} householdData={householdData} - submitted={ageErrorController.submittedCount} + submitted={submittedCount} /> ); }; @@ -393,8 +392,7 @@ const HouseholdDataBlock = ({ handleHouseholdDataSubmit }) => { const handleContinueSubmit = (event, validateInputFunction, inputToBeValidated, stepId, questionName, uuid) => { event.preventDefault(); - ageErrorController.incrementSubmitted(); - ageErrorController.updateError(householdData.age); + setSubmittedCount(submittedCount + 1); const validPersonData = personDataIsValid(householdData); const lastHouseholdMember = page >= remainingHHMNumber; @@ -425,7 +423,7 @@ const HouseholdDataBlock = ({ handleHouseholdDataSubmit }) => { hhMemberIndex={page} householdMemberData={hhMemberData} setHouseholdMemberData={setHHMemberData} - submitted={ageErrorController.submittedCount} + submitted={submittedCount} />

@@ -444,7 +442,7 @@ const HouseholdDataBlock = ({ handleHouseholdDataSubmit }) => {

{createIncomeRadioQuestion(page)}

- {householdData.hasIncome && createPersonIncomeBlock(ageErrorController.submittedCount)} + {householdData.hasIncome && createPersonIncomeBlock(submittedCount)}