From 90cdc4ec055768f43ecfd7aba4ac5250c76b4433 Mon Sep 17 00:00:00 2001 From: Gayathri Yedavilli Date: Sun, 28 Apr 2024 15:34:34 -0700 Subject: [PATCH] update endpoint to show registered events on volunteer home pg --- src/pages/VolunteerHomePage.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/VolunteerHomePage.jsx b/src/pages/VolunteerHomePage.jsx index d568445..aa0fbb9 100644 --- a/src/pages/VolunteerHomePage.jsx +++ b/src/pages/VolunteerHomePage.jsx @@ -15,6 +15,7 @@ import { SearchIcon, HamburgerIcon } from '@chakra-ui/icons'; import EventCard from '../components/Events/EventCard'; import VolunteerImpactSummary from '../components/Events/VolunteerImpactSummary'; +import UserContext from '../utils/UserContext'; import Backend from '../utils/utils'; import Fuse from 'fuse.js'; import NavbarContext from '../utils/NavbarContext'; @@ -29,9 +30,14 @@ const VolunteerHomePage = () => { const { onNavbarDrawerOpen } = useContext(NavbarContext); + const { user, updateUser } = useContext(UserContext); + const getEvents = async () => { try { - const eventsData = await Backend.get('/events'); + let userId = user?.id; + + const eventsData = await Backend.get(`data/registered/${userId}`); + console.log(eventsData); setEvents(eventsData.data); const options = { keys: ['name', 'date', 'location'], includeScore: true }; setFuse(new Fuse(eventsData.data, options)); @@ -47,6 +53,7 @@ const VolunteerHomePage = () => { )); useEffect(() => { + updateUser(); getEvents(); }, []);