Implement createVolunteer function#87
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
a1-su
left a comment
There was a problem hiding this comment.
Other than the email validation, LGTM! I might also remind the others to run supabase setup again once the PR is merged.
src/lib/api/createVolunteer.ts
Outdated
| (data["email"] as string).trim().length > 0 && | ||
| !isValidEmail(data["email"] as string) |
There was a problem hiding this comment.
I'm not sure if this is intentional, but the email validation allows empty strings as valid emails; presumably this should check for length === 0 || !isValidEmail(...)? I'm pretty sure just !isValidEmail(...) in itself would also work.
There was a problem hiding this comment.
Thanks for catching that! I ended up removing that check since we don't know exactly what type of annotations TRCC uses for the email field. For example, they might use "no email" or "double check: email@email.com" or something else.
This function adds a volunteer record to the database atomically by creating/updating Roles, Cohorts, VolunteerCohorts, and VolunteerRoles accordingly.
supabase:setupscript to run migrations since I implemented aplpgsqlscript as a migration file.plpgsqlmigration file creates an RPC (Remote Procedure Call) function calledcreate_volunteer_with_role_and_cohortlocally for testing purposes. I also created the same function in Supabase, remotely, to work with the main project.create_volunteer_with_role_and_cohortfunction creates volunteer with role and cohort in a single transaction.This PR consists of:
supabase:setupscript