Add updateGroupActivity method and corresponding route for editing group activities
This commit introduces the updateGroupActivity method in the diaryDateActivityController, allowing users to update existing group activities by linking them to predefined activities. The method includes error handling and emits a socket event upon successful updates. Additionally, the diaryDateActivityRoutes file is updated to include a new PUT route for updating group activities. Frontend changes in DiaryView enhance the user experience by enabling inline editing of group activities, including search functionality for predefined activities.
This commit is contained in:
@@ -391,6 +391,24 @@ class DiaryDateActivityService {
|
||||
return await GroupActivity.create(activityData);
|
||||
}
|
||||
|
||||
async updateGroupActivity(userToken, clubId, groupActivityId, predefinedActivityId) {
|
||||
await checkAccess(userToken, clubId);
|
||||
const groupActivity = await GroupActivity.findByPk(groupActivityId);
|
||||
if (!groupActivity) {
|
||||
throw new Error('Group activity not found');
|
||||
}
|
||||
|
||||
// Prüfe, ob die PredefinedActivity existiert
|
||||
const predefinedActivity = await PredefinedActivity.findByPk(predefinedActivityId);
|
||||
if (!predefinedActivity) {
|
||||
throw new Error('Predefined activity not found');
|
||||
}
|
||||
|
||||
// Aktualisiere die customActivity (die auf die PredefinedActivity verweist)
|
||||
groupActivity.customActivity = predefinedActivityId;
|
||||
return await groupActivity.save();
|
||||
}
|
||||
|
||||
async deleteGroupActivity(userToken, clubId, groupActivityId) {
|
||||
await checkAccess(userToken, clubId);
|
||||
const groupActivity = await GroupActivity.findByPk(groupActivityId);
|
||||
|
||||
Reference in New Issue
Block a user