From ac5552dc8bed9cb1172a391fe7d6276609a8aa72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Yoshida?= Date: Thu, 14 Dec 2023 01:41:46 -0300 Subject: [PATCH] [ADD] eletivas por trilhas --- .../controllers/LearningPathsController.js | 22 +++++++++++- backend/views/routes/LearningPaths.js | 2 +- frontend/src/pages/Home/index.js | 36 ++++++++++--------- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/backend/controllers/LearningPathsController.js b/backend/controllers/LearningPathsController.js index 16d8630e..d10b36bb 100644 --- a/backend/controllers/LearningPathsController.js +++ b/backend/controllers/LearningPathsController.js @@ -48,4 +48,24 @@ exports.FindLP = async (req, res) => { } catch (err) { res.status(400).json({ error: err.message }); } -} \ No newline at end of file +} + +exports.findElectives = async (req, res) =>{ + const learningPathId = req.params.learningPathId; + + try { + const learningPath = await LearningPath.findById(learningPathId); + + if (!learningPath) { + return res.status(404).json({ error: 'Trilha não encontrada' }); + } + + const electives = JSON.parse(learningPath.electives); + + res.status(200).json({ electives }); + } catch (error) { + console.error(error); + res.status(500).json({ error: 'Erro interno do servidor' }); + } +} + diff --git a/backend/views/routes/LearningPaths.js b/backend/views/routes/LearningPaths.js index ebd2cf54..1e668b04 100644 --- a/backend/views/routes/LearningPaths.js +++ b/backend/views/routes/LearningPaths.js @@ -6,6 +6,6 @@ router.post("/createLearningPaths", learningPathsController.createLearningPaths) router.delete("/deleteLearningPaths", learningPathsController.deleteLearningPaths) router.get('/learningpath', learningPathsController.LearningPath); router.post('/find_lp', learningPathsController.FindLP); - +router.get('/find_electives', learningPathsController.findElectives); module.exports = router; diff --git a/frontend/src/pages/Home/index.js b/frontend/src/pages/Home/index.js index 6399eb9b..135cd1f7 100644 --- a/frontend/src/pages/Home/index.js +++ b/frontend/src/pages/Home/index.js @@ -91,23 +91,25 @@ const Home = () => { - {currentRegistrationPeriod && ( -
- - Período de Matrícula Atual:{" "} - {`${new Date(currentRegistrationPeriod.start).toLocaleDateString()} às ${new Date( - currentRegistrationPeriod.start - ).toLocaleTimeString()} - ${new Date(currentRegistrationPeriod.end).toLocaleDateString()} às ${new Date( - currentRegistrationPeriod.end - ).toLocaleTimeString()}`} - -
- )} - -