Skip to content

Commit

Permalink
10353-bug: fix condition to re-enable button
Browse files Browse the repository at this point in the history
  • Loading branch information
Mwindo committed Aug 20, 2024
1 parent ed6e425 commit 027d771
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('Petitioner Account Creation', () => {
cy.get('@accountCreationRequest.all').should('have.length', 1);
});

it('should create an account and verify it using the verification link, then login and create an eletronic case', () => {
it('should create an account and verify it using the verification link, then login and create an electronic case', () => {
const TEST_EMAIL = `cypress_test_account+success_${GUID}@example.com`;
createAPetitioner({
email: TEST_EMAIL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { RequirementsText } from '@web-client/views/CreatePetitionerAccount/Requ
import { connect } from '@web-client/presenter/shared.cerebral';
import { debounce } from 'lodash';
import { sequences, state } from '@web-client/presenter/app.cerebral';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';

export const CreatePetitionerAccountForm = connect(
{
alertError: state.alertError,
alertWarning: state.alertWarning,
confirmPassword: state.form.confirmPassword,
createAccountHelper: state.createAccountHelper,
navigateToLoginSequence: sequences.navigateToLoginSequence,
Expand All @@ -19,6 +21,8 @@ export const CreatePetitionerAccountForm = connect(
updateFormValueSequence: sequences.updateFormValueSequence,
},
({
alertError,
alertWarning,
confirmPassword,
createAccountHelper,
navigateToLoginSequence,
Expand All @@ -33,9 +37,15 @@ export const CreatePetitionerAccountForm = connect(
const [inFocusName, setInFocusName] = useState(true);
const [submitDisabled, setSubmitDisabled] = useState(false);

// Re-enabled submit button if submission was unsuccessful
useEffect(() => {
if (alertError || alertWarning) {
setSubmitDisabled(false);
}
}, [alertError, alertWarning]);

const submitFunction = debounce(() => {
submitCreatePetitionerAccountFormSequence();
setSubmitDisabled(false);
}, 500);

return (
Expand Down Expand Up @@ -234,5 +244,3 @@ export const CreatePetitionerAccountForm = connect(
);
},
);

CreatePetitionerAccountForm.displayName = 'CreatePetitionerAccountForm';

0 comments on commit 027d771

Please sign in to comment.