Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds validation to fix email addresses. #1075

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

wjames111
Copy link
Contributor

Description

  • Tools - Fix Email Address - Add validation for edited email addresses
  • Ticket #8162

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@wjames111 wjames111 added On Staging Will be merged to the staging branch by Github Actions Preview Environment Add this label to create an Amplify Preview labels Sep 16, 2024
@wjames111 wjames111 self-assigned this Sep 16, 2024
@wjames111
Copy link
Contributor Author

This has a similar issue that fix commitment info tool has with the state and formik. Not 100% sure the best way to implement formik in this instance. I opted to just add to the mapped emails. The only real issue I found with this way is that the confirm button isn’t blocked when an illformed address is entered.

@wjames111 wjames111 requested a review from canac September 16, 2024 21:34
Copy link
Contributor

@canac canac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only real issue I found with this way is that the confirm button isn’t blocked when an illformed address is entered.

I saw a few times where typing an invalid email address and clicking Confirm sent the invalid email in the GraphQL mutation. But it appears that the server ignored it without returning an error. It's a little weird but probably OK.

It looks like we have a form inside of a form now. I'm not sure if that's bad or not, but if it needs to be changed, we can do that when we research performance. (EDIT: this is not true, I didn't read the code carefully).

Comment on lines 329 to 330
onSubmit={async (values) => {
await handleChange(id, index, values.newEmail);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleChange doesn't return a promise.

Suggested change
onSubmit={async (values) => {
await handleChange(id, index, values.newEmail);
onSubmit={(values) => {
handleChange(id, index, values.newEmail);

error={true}
data-testid="statusSelectError"
>
{errors.newEmail && errors.newEmail}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{errors.newEmail && errors.newEmail}
{errors.newEmail}

Copy link
Contributor

Copy link
Contributor

Bundle sizes [mpdx-react]

Compared against 67614f0

No significant changes found

@wrandall22
Copy link
Contributor

It looks like we have a form inside of a form now. I'm not sure if that's bad or not

Nested forms are not supported in HTML technically.

@wjames111
Copy link
Contributor Author

@wrandall22 Good to know. I'll rework this.

@wjames111
Copy link
Contributor Author

@canac I'm not seeing the nested form, am I missing something? I initially thought you were referring to the EmailValidationForm but it looks like that falls outside of the other form.

@canac
Copy link
Contributor

canac commented Sep 17, 2024

I'm not seeing the nested form, am I missing something?

You're right, I wasn't reading carefully. I thought FixEmailAddresses was using Formik, but it's just using a simple useState (which I think is the right choice).

I have no issues with the code you have here. Sorry for slowing this down!

@wjames111
Copy link
Contributor Author

@canac All good, thanks for looking it over!

@wjames111 wjames111 merged commit f06e55b into main Sep 17, 2024
17 of 18 checks passed
@wjames111 wjames111 deleted the MPDX-8162-fix-email-address-validation branch September 17, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On Staging Will be merged to the staging branch by Github Actions Preview Environment Add this label to create an Amplify Preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants