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

343 add validation to user signup form #363

Merged
merged 35 commits into from
Sep 11, 2023

Conversation

marvinsjsu
Copy link
Contributor

@marvinsjsu marvinsjsu commented Aug 2, 2023

Dev Summary

FIgma User SIgn Up flow

This adds validation to the fields in the User Sign Up form. It also refactors the UI into multiple step components and updates the display of errors to be under the field instead of under the label. This also adds redux for state management for user entity, and redux-thunk for sending the POST request to the backend to create the user account.

The work was starting to have scope-creep, so created some follow-up tickets:

Test Plan

To test, go to the User Signup form via http://localhost:3000/signup-citizen.

  • try to go through the form by entering invalid or missing values and see if proper error messages are displayed
  • verify that when all fields are filled with valid information, the user reaches the email verification step

Note:
During account creation on my local, I was getting an error regarding SendGrid -

await this.sendgridService.send(mail);
... I don't think I have a valid SENDGRID_API_KEY in my .env.

React-query tutorial: https://www.youtube.com/watch?v=r8Dg0KVnfMA


Object.keys(initialFormData).forEach((key) => {
//@ts-ignore
initialFormData[key].value = initData[key];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've used // @ts-ignore on multiple lines as an escape hatch as I'm not sure how to get this to work with TypeScript. If you guys have any ideas on how I could/should do this, that'd be awesome.

@EtoKruto
Copy link
Contributor

EtoKruto commented Aug 3, 2023

Regarding Passwords in the Video:

See video - I noticed that going back to the first password may still allow proceeding. Though this might be a minor correction since it's not typical user behavior, I thought it might be worth looking into. Nice work, looks clean

Screen.Recording.2023-08-03.at.12.06.56.AM.mov

@EtoKruto
Copy link
Contributor

EtoKruto commented Aug 3, 2023

On Titles and Styles(all pages):
I observed that the purple titles on each page don't exactly match the styles, but I like the direction you've taken with this, looks to be an improvement on the mock UI so I say keep it

About State/City Screen (Page 2):
The State/City screen in step 2 doesn't quite align with the mock, but I actually prefer it this way. Would make sense to add some validation with the Zip Code input but this could be a later add-on

Screenshot 2023-08-03 at 12 12 56 AM

@EtoKruto
Copy link
Contributor

EtoKruto commented Aug 3, 2023

Concerning the Upload Button Overlay:
I spotted an overlay issue with the upload button on the profile photo. I know there's another story for this HERE, so it may be out of scope, but I thought it worth mentioning

@EtoKruto
Copy link
Contributor

EtoKruto commented Aug 3, 2023

Console Log Clean-Up:
Once ready, clean up any console.log entries

@EtoKruto
Copy link
Contributor

EtoKruto commented Aug 3, 2023

Error with 'Bio' Column in UsersService:
I encountered an error related to the 'bio' column of the 'users' relation when clicking next on from the profile icon/about me page.

ERROR [UsersService] column "bio" of relation "users" does not exist: 
QueryFailedError: column "bio" of relation "users" does not exist
    at PostgresQueryRunner.query

In addition this also overlayed the words "Loading" over the back button (see screenshot)

Since I'm not as familiar with the backend, I feel it might be beneficial to have someone more familiar with the backend take a look at this part of the project

Overall Great job, really like what you did here and there is a lot of good work here!

Copy link
Contributor

@esteban-gs esteban-gs left a comment

Choose a reason for hiding this comment

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

@marvinsjsu , thanks for working on this. If we want to use redux going forward, we'll probably need to update other forms and remove other libraries (probably for another PR).

@@ -9,6 +9,7 @@
"@mui/base": "^5.0.0-beta.2",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.2",
"@reduxjs/toolkit": "^1.9.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

@marvinsjsu , do we want to settle on redux without any other form library? If so, we'll also want to add some cards to remove react-query and react-hooks-form. There are a few forms (signupnonprofit) using it. I like Redux' separation of concerns, but one downside is all the boilerplate.

Either way, I'm down with it.

@marvinsjsu
Copy link
Contributor Author

hi @esteban-gs and @EtoKruto, I've updated this PR based on the feedback, but I'm going to work on the styling in the other ticket I have - https://github.com/orgs/Nonprofit-Exchange-Hub/projects/14?pane=issue&itemId=33617416 (since this PR is getting kinda big and the other ticket is more for styling changes anyways). I think it's ready for another look. Thanks guys!

@marvinsjsu marvinsjsu self-assigned this Sep 7, 2023
@marvinsjsu marvinsjsu marked this pull request as ready for review September 7, 2023 17:30
@marvinsjsu marvinsjsu linked an issue Sep 8, 2023 that may be closed by this pull request
Copy link
Contributor

@esteban-gs esteban-gs left a comment

Choose a reason for hiding this comment

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

@marvinsjsu , thank you for tackling this! I think we are getting close to being ready. I left a couple of comments and one blocking comment about the last step not working as intended.

Comment on lines 106 to 108
<Button type="submit" color="primary" variant="outlined">
Next
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Step 4 data (bio) isn't getting merged with the rest of the data. Maybe you need to call the handleNext parent method as well.

Comment on lines 69 to 73
const { status, data } = useQuery({
queryKey: ['user-email-exists', formData['email'].value],
queryFn: () => Endpoints.checkUserEmail(formData['email'].value),
enabled: userEmailQueryEnabled,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should leave this query out of this iteration until we define this further. What do you think?


const makeChips = () => {
return interests.map((interest) => {
// TODO: toggle chip style when interest is chosen
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
// TODO: toggle chip style when interest is chosen

Comment on lines 74 to 84
@Get('user-email-exists/:email')
@ApiOperation({ summary: 'Check if a user email already exists.' })
async userEmailExists(@Param('email') email: string) {
try {
const user = await this.usersService.findByEmail(email);
return Boolean(user);
} catch (error) {
return false;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion is to leave this new public endpoint out of this PR until we solve this issue further.

Suggested change
@Get('user-email-exists/:email')
@ApiOperation({ summary: 'Check if a user email already exists.' })
async userEmailExists(@Param('email') email: string) {
try {
const user = await this.usersService.findByEmail(email);
return Boolean(user);
} catch (error) {
return false;
}
}

@marvinsjsu
Copy link
Contributor Author

marvinsjsu commented Sep 10, 2023

@esteban, thanks for catching the bug with bio. This should be fixed now and I've also removed the email check. This should be ready for another look.

Copy link
Contributor

@esteban-gs esteban-gs left a comment

Choose a reason for hiding this comment

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

There is one linting rule exception comment that's tripping up the build. LGTM after that's addressed 🚢

Comment on lines 75 to 78
// eslint-disable-next-line prettier/prettier
doSubmit
? setSubmitForm(true)
: setActiveStep((prevActiveStep) => prevActiveStep + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

prettier doesn't like this in-line warning disabling comment. See the build errors.

You should be able to just format it in a single line to get rid of the lint warning.

Suggested change
// eslint-disable-next-line prettier/prettier
doSubmit
? setSubmitForm(true)
: setActiveStep((prevActiveStep) => prevActiveStep + 1);
doSubmit ? setSubmitForm(true) : setActiveStep((prevActiveStep) => prevActiveStep + 1);

@marvinsjsu marvinsjsu merged commit 427becc into main Sep 11, 2023
3 checks passed
@marvinsjsu marvinsjsu deleted the 343-add-validation-to-user-signup-form branch September 11, 2023 00:29
@garimacha
Copy link

@marvinsjsu This PR is under review but its not under the In progress vertical. Shouldn't this be moved under in progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finish User Sign Up Form
4 participants