Fixed format of events

This commit is contained in:
Torsten Schulz
2024-06-23 17:32:45 +02:00
parent 692e989861
commit 8b89d8b800
26 changed files with 455 additions and 157 deletions

View File

@@ -18,6 +18,28 @@ const getAllInstitutions = async (req, res) => {
}
};
const getInstitutionById = async (req, res) => {
try {
const { id } = req.params;
const institution = await Institution.findByPk(id, {
include: [
{
model: ContactPerson,
as: 'contactPersons',
through: { attributes: [] }
}
]
});
if (!institution) {
return res.status(404).json({ error: 'Institution not found' });
}
res.json(institution);
} catch (error) {
res.status(500).json({ error: 'Failed to fetch institution' });
console.error(error);
}
};
const createInstitution = async (req, res) => {
try {
const { contactPersonIds, ...institutionData } = req.body;
@@ -70,6 +92,7 @@ const deleteInstitution = async (req, res) => {
module.exports = {
getAllInstitutions,
getInstitutionById,
createInstitution,
updateInstitution,
deleteInstitution