-
Notifications
You must be signed in to change notification settings - Fork 1
Description
🎯 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
Usermodels.add-senior.tsxhas a dropdown of potential student names; so, replace thedropDataparameter in the<AddProfile>with these names! - Then, build your new
Seniormodel. You'll populate fields likenameandlocationwith the data passed into thehandleSubmit()function. Other fields are more specific:StudentIDsandStudentswill describe all associatedUsers. A newSeniorhas 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.idvalue: this is what you'll store in theSeniormodel'sfolderfield, so thatSenior'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.