diff --git a/src/pages/VolunteerHomePage.jsx b/src/pages/VolunteerHomePage.jsx index cf3fcb1..5b92b94 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(); }, []);