You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have the button, we have the back-end function, now is the time!!!!!
Summary 💻
In this ticket, you will be making the filter modal work! With this ticket done, we will be able to filter tutees by grade preference, subject preference, disability preference, and tutoring mode.
Deliverables 🚀
Schedule at least two meetings as a pair
Create a new branch using the "create a branch" button
If you go into TuteeTable.tsx, you can see that right now, we are simply displaying every tutee in the database from the useEffect fetch. This is done by fetching from the GET request endpoint in backend/src/index.ts -- take a look to see how this works. Your job is to alter the useEffect and GET request endpoint to ONLY display the tutees given the current filter.
The useEffect is currently only running when the page initially loads since it has an empty dependency array ([]). Change the dependency array to hold the useState values of the filter such that when these values change, the useEffect runs again. Console.log something in the useEffect to see if it outputs to the console every time these values change.
Now, you want your endpoint to only return the tutees that meet the given filter. So, you want your fetch to pass in the current filter information. You can use the following format to pass in this information to the endpoint you made: const response = await fetch("http://localhost:3000/tutees", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(filterData),});
Now, with the information passed to your endpoint, you can extract all the filter variables with const {information1, information2, ...} = req.body. Console.log this data to see if it was passed in correctly.
Finally, you can filter the tutees from the tutee table given the current filters. Thankfully the filter function was already made for you so you just need to call filterTutors() and call res.json() on what it returns. Verify that the filter works and yay you're done, amazing work.
Tip for success 📈
Use npx tsx src/index.ts to run the backend server
We have the button, we have the back-end function, now is the time!!!!!
Summary 💻
In this ticket, you will be making the filter modal work! With this ticket done, we will be able to filter tutees by grade preference, subject preference, disability preference, and tutoring mode.
Deliverables 🚀
/tutees
get request endpointSteps 👍
TuteeTable.tsx
, you can see that right now, we are simply displaying every tutee in the database from theuseEffect
fetch. This is done by fetching from the GET request endpoint inbackend/src/index.ts
-- take a look to see how this works. Your job is to alter theuseEffect
and GET request endpoint to ONLY display the tutees given the current filter.useEffect
is currently only running when the page initially loads since it has an empty dependency array ([]
). Change the dependency array to hold theuseState
values of the filter such that when these values change, theuseEffect
runs again. Console.log something in theuseEffect
to see if it outputs to the console every time these values change.const response = await fetch("http://localhost:3000/tutees", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(filterData),});
const {information1, information2, ...} = req.body
. Console.log this data to see if it was passed in correctly.filterTutors()
and callres.json()
on what it returns. Verify that the filter works and yay you're done, amazing work.Tip for success 📈
npx tsx src/index.ts
to run the backend serverWhere to get help!
Reach out to @dilanurbayraktar and @brandondionisio.
The text was updated successfully, but these errors were encountered: