codefordenver / partner-finder

Using an open dataset with registered colorado business to build a tool that manages outreach to potential CFD partners.
3 stars 14 forks source link

Feature/validation create lead form #222

Closed clairefields15 closed 2 years ago

clairefields15 commented 3 years ago

Description

Add form validation to the create lead form. Validation includes: -company name is a required field -phone number is 10 numbers long -facebook, instagram, linkedin, twitter and website are all valid urls (using regex)

When you click the Save button all of these inputs will be validated and errors will appear on the UI if anything is incorrect. Each subsequent time you click Save, the error messages reset (so let's say you have 5 errors the first time you click, and you fix all but 1 and click Save again, you will only see 1 error message instead of all 5 persisting)

The form fields clear when you click Reset, they also clear when you click Back.

If there are no errors with your input, a newLead is created and added.

As of 6pm 10/25, I pulled down and merged all new changes from main into this branch

Fixes #145

Type of Change:

Code/Quality Assurance Only

How Has This Been Tested?

Creating many new leads with incorrect inputs, then correcting them and seeing if I am able to submit the form.

Checklist:

Code/Quality Assurance Only

clairefields15 commented 3 years ago

I addressed some of the comments but not the repetition in the JSX. I also wonder if the error handling in the UI could be nicer/smaller. Like maybe instead of each input field having it's own error state, there is just one error state at the top of the form that lists all of the potential errors, like:

Please correct the following errors in the form:
-Company name is required
-Valid username is required
-Phone number must be 10 digits long
-All urls must be formatted correctly(http://www.example.com)
clairefields15 commented 2 years ago

Refactored so there is no more direct DOM manipulation and everything works. Merging now!