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

[Backend] User Schema + API Routes #3

Closed
wkim10 opened this issue Oct 10, 2024 · 0 comments · Fixed by #19
Closed

[Backend] User Schema + API Routes #3

wkim10 opened this issue Oct 10, 2024 · 0 comments · Fixed by #19
Assignees
Labels

Comments

@wkim10
Copy link
Collaborator

wkim10 commented Oct 10, 2024

Description

Part 1: Creating the User and VolunteerDetails Schemas

We have defined a partial User schema in schema.prisma. A User will encompass both Volunteer and Admin roles, which will be differentiated by the “Role” field. However, a Volunteer will have many additional fields that an Admin will not have. Because of this, we think it will be best to create a schema called “VolunteerDetails” that will have a one-to-one relation with the User schema, which will contain the additional fields that Volunteers have.

So your task is to add the remaining fields to the User schema and create a new VolunteerDetails schema:

  • Role
  • Last Name

VolunteerDetails Schema:

  • First Name
  • Last Name
  • Email
  • Are they over the age of 14?
  • Country
  • Address
  • City
  • State
  • ZIP Code
  • If they have a driver’s license?
  • Do you speak Spanish?
  • Volunteer Type (Individual Volunteer, Community Group, Corporate Team, Youth Group) (Reasoning for volunteering? + Other/Followup)
  • Days available
  • Time of day available (daytime/evening/anytime)
  • On what basis they plan to volunteer (one-time/weekly/biweekly/monthly, etc)
Screen Shot 2024-10-10 at 7 50 57 PM

If you're not too familiar with Prisma, the schema fields that are already defined should help you, and you should definitely read up on the documentation to learn more about the syntax: https://www.prisma.io/docs/orm/prisma-schema/overview

Part 2: Creating the User API Routes

After doing that, we need to create API routes to update (PUT) and delete (DELETE) a User. If you go into src/app/api/user/route.ts, you can see that we made an example POST request for the current User Type. We also have a function called addUser in src/app/api/user/route.client.ts that calls the POST request. Try to follow a similar logic to this when implementing your own routes in the same files.

This might seem like a lot, but we’re here for you so don’t stress! Focus first on finishing the schemas. After checking in with us, you can move onto creating the API routes! If you ever need any help or are stuck on any new terms or concepts make sure to reach out whenever! :)

Testing

Like we said before, once you get the schema done, make sure to reach out to us so we can go over it together!

To test your backend routes and APIs, you can call the API on the frontend with a simple button. You can hard code data and pass it into your API, like the test button example we have in src/components/ExampleButton.tsx. Go to MongoDB Atlas and see if your operations happened as expected.

Once you have thoroughly tested, feel free to make a PR (Pull Request).

@wkim10 wkim10 added the backend label Oct 10, 2024
@wkim10 wkim10 assigned ConradHsu and ManuP6789 and unassigned ConradHsu Oct 18, 2024
@ManuP6789 ManuP6789 linked a pull request Oct 30, 2024 that will close this issue
wkim10 added a commit that referenced this issue Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants