Skip to content

Ticket: Hooking up AddSenior #49

@sgilfeather

Description

@sgilfeather

🎯 Due April 12th, 2023
Taarika Bala, Siara Small, Alex Lee, Alyssa Williams

Your task for this week and a half is to add functionality to the AddSenior page, so that you can generate a new model and store it on submission of the form!

Specifically, you'll be writing the handleSubmit functions specified in add-senior.tsx. Don't worry about the event parameter passed in; you'll be using the properties in seniorData to construct a new model.

  • First, you'll want to retrieve a list of the current Students, represented by User models.add-senior.tsx has a dropdown of potential student names; so, replace the dropData parameter in the <AddProfile> with these names!
  • Then, build your newSenior model. You'll populate fields like name and location with the data passed into the handleSubmit() function. Other fields are more specific:StudentIDs and Students will describe all associated Users. A new Senior has no files. Furthermore, on creation of a new senior, you'll want to give them a unique folder in Google Drive...
  • Use the Google Drive API to create a new folder under the JumboCode gmail account. Use the code shown here in the Google Drive API, under Node.js, for reference on how to create a new folder: here. Save the file.data.id value: this is what you'll store in the Senior model's folder field, so that Senior's files can be retrieved later.

Finally, create and push your new model. You'll be using your function written in src/pages/api/senior/add.ts. Check out the handleSubmit() code snippet below from refine.dev on how to use your routes.

  function handleSubmit(e) {
    e.preventDefault();
    const postData = async () => {
      const data = {
        title: title,
        post: post,
      };

      const response = await fetch("/api/post", {
        method: "POST",
        body: JSON.stringify(data),
      });
      return response.json();
    };
    postData().then((data) => {
      alert(data.message);
    });
  }

We anticipate that the Google Drive part will be a little trickier– reach out to me or Michael if you have any questions.

Metadata

Metadata

Assignees

Labels

ticketWeekly developer ticket

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions