Fixed format of events
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user