-
Notifications
You must be signed in to change notification settings - Fork 0
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
Senior form feedback #151
Senior form feedback #151
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
44a2914
to
54e012d
Compare
src/components/AddSenior.tsx
Outdated
px-4 py-2 text-[18px] font-normal text-dark-teal drop-shadow-md duration-300 hover:bg-off-white" | ||
type="submit" | ||
style={ | ||
edited |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making it invisible, we should have it dimmed and unclickable.
resolver: zodResolver(seniorFormSchema), | ||
}); | ||
|
||
const onSubmit: SubmitHandler<SeniorData> = async (data, event) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the data needs to validated before making the API request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data is automatically validated because we pass in the zodResolver function to the useForm hook.
src/components/AddSenior.tsx
Outdated
firstname: e.target.value, | ||
}) | ||
} | ||
{...register("firstname")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we display error message here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
src/components/AddSenior.tsx
Outdated
const [selectedStudents, setSelectedStudents] = useState<User[]>([]); | ||
const [currentImage, setCurrentImage] = useState<string | StaticImageData>( | ||
ImageIcon | ||
); | ||
const [confirm, setConfirm] = useState<boolean>(false); | ||
const [error, setError] = useState<boolean>(false); | ||
const [edited, setEdited] = useState<boolean>(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may not be necessary if we still display the save
button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to dim the save button now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are moving in the right direction! I did a rebase and remove unused variables from AddSenior
. A couple details to consider:
- I think we should still display the
save
button as it looks weird without. - Maybe we should considering displaying error messages.
- We should update
seniorSchema
to have a min-required length for firstname and lastname. What do you think would be a good constraint @cledi01?
827a39e
to
0c6481e
Compare
Added a constraint for the firstname to have a minimum of 2 characters, I wasn't sure if we needed a last name constraint so I held off on that. Error message also pops up if firstname is less than 2 chars. Submit button is now dimmed and disabled until user makes an edit in the form. |
Fix commit booboo part 2 Fix commit boo boo part 3
0c6481e
to
0a300eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are fantastic, thank you! I rebased the branch and updated the logic when we allow users' to submit per discussion.
Description
Updated the add/update senior form pop-up to be compatible with the react-hook-form module. Also made the submit button only visible when fields have been edited.
Issues
#124
Test
To test, go to http://localhost:3000/private/chapter-leader/seniors
Make sure to make yourself a chapter-leader beforehand on the database manually to get to this page.
Possible Downsides
When testing, I didn't have google folder access to the chapter's folder (you only get access through a certain workflow which I bypassed by directly editing the role field through npx prisma studio), so when adding a new senior there was an error that came up. However, the database reflects the new senior correctly.
Additional Documentations