Fixed group activities and added collapsing for general settings
This commit is contained in:
@@ -26,4 +26,17 @@ const getGroups = async(req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
export { addGroup, getGroups };
|
||||
const changeGroup = async(req, res) => {
|
||||
try {
|
||||
const { authcode: userToken } = req.headers;
|
||||
const { groupId } = req.params;
|
||||
const { clubid: clubId, dateid: dateId, name, lead } = req.body;
|
||||
const result = await groupService.changeGroup(userToken, groupId, clubId, dateId, name, lead);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
console.error('[changeGroup] - Error:', error);
|
||||
res.status(error.statusCode || 500).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
export { addGroup, getGroups, changeGroup};
|
||||
@@ -1,10 +1,13 @@
|
||||
import express from 'express';
|
||||
import { authenticate } from '../middleware/authMiddleware.js';
|
||||
import { addGroup, getGroups } from '../controllers/groupController.js';
|
||||
import { addGroup, getGroups, changeGroup } from '../controllers/groupController.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post('/', authenticate, addGroup);
|
||||
router.get('/:clubId/:dateId', authenticate, getGroups);
|
||||
router.use(authenticate);
|
||||
|
||||
router.post('/', addGroup);
|
||||
router.get('/:clubId/:dateId', getGroups);
|
||||
router.put('/:groupId', changeGroup);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -144,7 +144,7 @@ class DiaryDateActivityService {
|
||||
diaryDateId,
|
||||
isTimeblock: true,
|
||||
},
|
||||
order: [['order_id', 'ASC']],
|
||||
order: [['order_id', 'DESC']],
|
||||
limit: 1
|
||||
});
|
||||
if (!diaryDateActivity) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class DiaryService {
|
||||
{ model: DiaryNote, as: 'diaryNotes' }, // Der Alias für DiaryNote ist korrekt
|
||||
{ model: DiaryTag, as: 'diaryTags' }, // Hier muss der Alias auf 'diaryTags' geändert werden
|
||||
],
|
||||
order: [['date', 'ASC'], ['trainingStart', 'ASC']]
|
||||
order: [['date', 'DESC'], ['trainingStart', 'ASC']]
|
||||
});
|
||||
return dates;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,25 @@ class GroupService {
|
||||
});
|
||||
return groups;
|
||||
}
|
||||
|
||||
async changeGroup(userToken, groupId, clubId, dateId, name, lead) {
|
||||
console.log("changeGroup: ", groupId, clubId, dateId, name, lead);
|
||||
await checkAccess(userToken, clubId);
|
||||
await this.checkDiaryDateToClub(clubId, dateId);
|
||||
const group = await Group.findOne({
|
||||
where: {
|
||||
id: groupId,
|
||||
diaryDateId: dateId
|
||||
}
|
||||
});
|
||||
if (!group) {
|
||||
throw new HttpError('Gruppe nicht gefunden oder passt nicht zum angegebenen Datum und Verein', 404);
|
||||
}
|
||||
group.name = name;
|
||||
group.lead = lead;
|
||||
await group.save();
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
export default new GroupService();
|
||||
Reference in New Issue
Block a user