Skip to content

Commit

Permalink
[FIX] registration period
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaryoshida committed Dec 14, 2023
1 parent 4ef4812 commit cbb8edf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions backend/controllers/SuperuserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ exports.openRegistrationPeriod = async (req, res) => {

exports.getRegistrationPeriod = async (req, res) => {
try {
const currentPeriod = await Registration.findOne({
where: { id: 1 }
const mostRecentPeriod = await Registration.findOne({
order: [['createdAt', 'DESC']]
});
if (!currentPeriod) {

if (!mostRecentPeriod) {
res.status(404).json({ error: 'Período de matrícula não encontrado.' });
return;
}
res.json(currentPeriod);

res.json(mostRecentPeriod);
} catch (error) {
console.error('Erro ao buscar o período de matrícula atual:', error);
res.status(500).json({ error: 'Erro ao buscar o período de matrícula atual.' });
console.error('Erro ao buscar o período de matrícula mais recente:', error);
res.status(500).json({ error: 'Erro ao buscar o período de matrícula mais recente.' });
}
};
};

1 comment on commit cbb8edf

@vercel
Copy link

@vercel vercel bot commented on cbb8edf 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.vercel.app
matriculai-matriculai.vercel.app
matriculai-git-main-matriculai.vercel.app

Please sign in to comment.