Skip to content

Commit

Permalink
Merge pull request #4128 from Succorro/WV-482
Browse files Browse the repository at this point in the history
WV-482 Email Analysis fixes
  • Loading branch information
DaleMcGrew authored Oct 24, 2024
2 parents 941c9dc + 3979427 commit 4f72e2f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
14 changes: 6 additions & 8 deletions src/js/common/components/Donation/CheckoutForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DonateStore from '../../stores/DonateStore';
import { renderLog } from '../../utils/logging';
import moneyStringToPennies from '../../utils/moneyStringToPennies';
import SplitIconButton from '../Widgets/SplitIconButton';

import { validateEmail } from '../../../utils/regex-checks';

const iconButtonStyles = {
width: window.innerWidth < 1280 ? 250 : 300,
Expand Down Expand Up @@ -222,24 +222,22 @@ class CheckoutForm extends React.Component {
}

emailChange = (event) => {
const currentEntry = event.target.value;
const validEmailPattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
const valid = currentEntry.match(validEmailPattern) != null;
console.log('valid? : ', currentEntry, ' valid: ', valid);
const currentEmail = event.target.value;
const currentEmailIsValid = validateEmail(currentEmail);
if (this.emailErrorTimer) clearInterval(this.emailErrorTimer);
if (!valid) {
if (currentEmail && !currentEmailIsValid) {
this.emailErrorTimer = setTimeout(() => {
this.setState({
emailFieldError: true,
emailFieldText: currentEntry,
emailFieldText: currentEmail,
emailValidationErrorText: 'Our payment processor requires a valid email address',
});
this.emailErrorTimer = null;
}, 1500);
} else {
this.setState({
emailFieldError: false,
emailFieldText: currentEntry,
emailFieldText: currentEmail,
emailValidationErrorText: '',
});
}
Expand Down
12 changes: 7 additions & 5 deletions src/js/common/components/Settings/CompleteYourProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import VoterFirstNameInputField from './VoterFirstNameInputField';
import VoterLastNameInputField from './VoterLastNameInputField';
import CandidateStore from '../../../stores/CandidateStore';
import RepresentativeStore from '../../../stores/RepresentativeStore';
import { validateEmail } from '../../../utils/regex-checks';

const SignInButton = React.lazy(() => import(/* webpackChunkName: 'SignInButton' */ '../Navigation/SignInButton'));
// const SignInModalController = React.lazy(() => import(/* webpackChunkName: 'SignInModalController' */ './SignInModalController'));
Expand Down Expand Up @@ -182,11 +183,12 @@ class CompleteYourProfile extends Component {
voterEmailMissing = true;
}
if (voterEmailQueuedToSave) {
// Check to see if valid email format
// if so,
this.setState({
voterEmailQueuedToSaveLocal: voterEmailQueuedToSave,
});
const voterEmailQueuedToSaveIsValid = validateEmail(voterEmailQueuedToSave);
if (voterEmailQueuedToSaveIsValid) {
this.setState({
voterEmailQueuedToSaveLocal: voterEmailQueuedToSave,
});
}
}
if (!voterFirstNameQueuedToSave && !VoterStore.getFirstName()) {
voterFirstNameMissing = true;
Expand Down
10 changes: 5 additions & 5 deletions src/js/components/Settings/VoterEmailAddressEntry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ class VoterEmailAddressEntry extends Component {
this.setState({
displayEmailVerificationButton: false,
});
const TermsOfServiceLink = document.getElementById("openTermsOfService");
const TermsOfServiceLink = document.getElementById('openTermsOfService');
if (TermsOfServiceLink) {
TermsOfServiceLink.focus();
TermsOfServiceLink.focus();
}
blurTextFieldAndroid();
}
}
};

onCancel = () => {
Expand All @@ -271,9 +271,9 @@ class VoterEmailAddressEntry extends Component {
this.props.showAllSignInOptions();
}
}
const TermsOfServiceLink = document.getElementById("openTermsOfService");
const TermsOfServiceLink = document.getElementById('openTermsOfService');
if (TermsOfServiceLink) {
TermsOfServiceLink.focus();
TermsOfServiceLink.focus();
}
};

Expand Down
22 changes: 11 additions & 11 deletions src/js/pages/WelcomeForCampaigns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ class WelcomeForCampaigns extends PureComponent {
});
};

updateVoterEmailAddress = (event) => {
const isEmailValid = validateEmail(event.target.value);
let submitEnabled = false;
if (isEmailValid) {
submitEnabled = true;
}
// updateVoterEmailAddress = (event) => {
// const isEmailValid = validateEmail(event.target.value);
// let submitEnabled = false;
// if (isEmailValid) {
// submitEnabled = true;
// }

this.setState({
voterEmail: event.target.value,
submitEnabled,
});
};
// this.setState({
// voterEmail: event.target.value,
// submitEnabled,
// });
// };

voterEmailAddressSignUpSave = (event) => {
// Only proceed after we have a valid email address, which will enable the submit
Expand Down

0 comments on commit 4f72e2f

Please sign in to comment.