Skip to content

Commit

Permalink
[ADD] eletivas por trilhas
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaryoshida committed Dec 14, 2023
1 parent cbb8edf commit ac5552d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
22 changes: 21 additions & 1 deletion backend/controllers/LearningPathsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,24 @@ exports.FindLP = async (req, res) => {
} catch (err) {
res.status(400).json({ error: err.message });
}
}
}

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' });
}
}

2 changes: 1 addition & 1 deletion backend/views/routes/LearningPaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
36 changes: 19 additions & 17 deletions frontend/src/pages/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,25 @@ const Home = () => {
</HStack>
</Center>

{currentRegistrationPeriod && (
<Center>
<Text fontSize="lg" color="#243A69" marginTop="2vh">
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()}`}
</Text>
</Center>
)}
</Container>
<Footer />
</Flex>
</ChakraProvider>
);
{currentRegistrationPeriod && (
<Center>
<Text fontSize="lg" color="#243A69" marginTop="2vh">
Período de matrícula atual:{" "}
{`${new Date(currentRegistrationPeriod.start).toLocaleDateString()} às ${new Date(
new Date(currentRegistrationPeriod.start).getTime() + (new Date(currentRegistrationPeriod.start).getHours() < 3 ? 25 : 3) * 60 * 60 * 1000
).toLocaleTimeString()} - ${new Date(currentRegistrationPeriod.end).toLocaleDateString()} às ${new Date(
new Date(currentRegistrationPeriod.end).getTime() + 3 * 60 * 60 * 1000
).toLocaleTimeString()}`}
</Text>
</Center>
)}


</Container>
<Footer />
</Flex>
</ChakraProvider>
);
};

export default Home;

1 comment on commit ac5552d

@vercel
Copy link

@vercel vercel bot commented on ac5552d Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

matriculai – ./frontend

matriculai-matriculai.vercel.app
matriculai.vercel.app
matriculai-git-main-matriculai.vercel.app

Please sign in to comment.