Skip to content

Commit

Permalink
get registered events for volunteer home page
Browse files Browse the repository at this point in the history
  • Loading branch information
gayathriy22 committed Apr 28, 2024
1 parent 2339448 commit c923296
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions routes/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,22 @@ dataRouter.get('/images/:volunteerId', async (req, res) => {
}
});

dataRouter.get('/registered/:volunteerId', async (req, res) => {
// retrive registered events associated with the volunteerID
try {
const { volunteerId } = req.params;
const allEvents = await pool.query(
`SELECT events.*
FROM events
INNER JOIN event_data ON events.id = event_data.event_id
WHERE event_data.volunteer_id = $1
ORDER BY events.date DESC;`,
[volunteerId],
);
res.status(200).json(allEvents.rows);
} catch (err) {
res.status(500).send(err.message);
}
});

module.exports = dataRouter;

0 comments on commit c923296

Please sign in to comment.