Assignment 4 In this assignment we will be connecting to a database directly through our…
- User
Assignment 4
In this assignment we will be connecting to a database directly through our frontend!
Step 0 - Setup
Create a Next.js using our starter code with the following command:
yarn create next-app --typescript --example "https://github.com/cornell-dti/trends-sp23-a4" YOUR_PROJECT_NAME Create a Firebase Project
For this assignment, you will be setting up your own Firebase project. You will be connecting your Next.js web app to the Firestore database to store task data.
See Ed for more specific Firebase setup instructions.
Step 1 - Finding One's Bearings
As with A2/A3, run yarn dev in the project directory to start the server and navigate to localhost:3000 to see what the starter code gives you.
In this assignment we will be implementing a simple task/todo list with add/delete functionality. Each task can also be "checked off" to denote being completed.
Tasks will be stored in our Firestore database, within a collection called tasks. Each document in the collection will represent a single task, containing information such as the text/name of the task, as well as whether is checked off.
Here are the important files you'll be working with:
React Components util/firebase.ts Utility file for all Firebase-related exports. We initialize the Firebase app here, so this is the place to paste your firebaseConfig. components/frodo/Frodo.tsx Overall "todo list" component. We store a list of tasks in the state which gets passed down and displayed in children components. components/frodo/TaskAddControl.tsx Component for adding a new task to the task list. Instead of updating state directly, we will perform a database operation in order to add a task. components/frodo/TaskList.tsx Simple "intermediate" component that maps over a list of tasks. components/frodo/TaskItem.tsx Component for displaying a task's information. Has a toggleable checkbox and a "delete" button Other Files types/index.ts Task is a simple schema for a task. Firebase documents that represent tasks should match this schema. TaskWithId is a type that has every property in Tasks PLUS the id property, which represents the task's Firebase document id. As always, make sure to fill in all the TODOs before submitting!
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.