diff --git a/controllers/schedule.js b/controllers/schedule.js index 56067f5d0b13da499397876b33fe0b0da2c6a18d..2bea511af3362c75482078aaa41d8a1c6272cde7 100644 --- a/controllers/schedule.js +++ b/controllers/schedule.js @@ -39,3 +39,17 @@ exports.createMySchedules = async (req, res, next) => { return next(error); } }; + +exports.getMySchedules = async (req, res, next) => { + const participantId = getLoggedInParticipantId(req, res, next); + try { + const mySchedules = await Schedule.findAll({ + where: { + ParticipantId: participantId, + }, + }); + return res.json(SchedulesResponse.from(mySchedules)); + } catch (error) { + return next(error); + } +}; diff --git a/routes/mySchedule.js b/routes/mySchedule.js index 20991dbdd65cf1833be185e2795e291d5de0d83b..6e6291dbea08f6a70a51f27ad42dbe448f75e29f 100644 --- a/routes/mySchedule.js +++ b/routes/mySchedule.js @@ -1,9 +1,14 @@ const express = require('express'); const { isAuthenticated } = require('../middlewares/auth'); -const { createMySchedules } = require('../controllers/schedule'); +const { + createMySchedules, + getMySchedules, +} = require('../controllers/schedule'); const router = express.Router({ mergeParams: true }); router.post('/bulk', isAuthenticated, createMySchedules); +router.get('/', isAuthenticated, getMySchedules); + module.exports = router;