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

created functions to create/edit/delete questions #16

Merged
merged 13 commits into from
Apr 8, 2024

Conversation

throwExceptionPlease
Copy link
Collaborator

Created functions for creating, editing, and deleting questions using batchUpdate and passing through the proper requestBody into the function.

handler: An attempt to connect the client and the server side for using the create, edit, and delete functions. This part was a bit iffy for me because I'm still trying to get familiar with this concept.

None of the create/edit functions do any type checking. Not sure if this is needed due to the wide range of question types, option types, etc. Therefore, these functions were created with the assumption that when used, the question to add or the edited version of the question will be in the proper format and have the required fields.

Create/edit functions use createItem and updateItem respectively, and the question fields are set with the passed-in questions. These union fields will be sent as their corresponding Request types in batchUpdate.

The delete function should do as expected--it should refer to the passed-in index of the question that needs to be deleted via union field of deleteItem and sent as a DeleteItemRequest in batchUpdate.

Finally, each function should update the corresponding form document in firebase with the modified data.

See the documentation in the code for more.

@throwExceptionPlease
Copy link
Collaborator Author

Recent updates:

  • Removed the functions involving editing the form since they were no longer needed
  • Removed original forms.ts--for some unknown reason, i made a separate .ts file for the new function so I just removed the original form and renamed the new one.
  • Added updateForm function which will retrieve and update the form to the db. So far, it doesn't return anything.
  • Only one file was edited: formFunctions.ts. The rest were from pulls.

@ukataria ukataria self-requested a review March 31, 2024 21:39
@throwExceptionPlease
Copy link
Collaborator Author

Update:

  • Edited form function after realizing that the getDoc wouldn't get the document with the matched formId field. To address this, I used query() to match the formId field to the given id.

@@ -0,0 +1,22 @@
import {forms } from '../../../lib/googleAuthorization';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this file in /src/lib/forms, shouldn't be an API endpoint

@nkanchinadam nkanchinadam merged commit 20ae699 into main Apr 8, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants