Add group deletion functionality and socket event emissions for real-time updates

This commit introduces the ability to delete groups in the groupController, along with the necessary backend service updates. It also adds socket event emissions for group and activity changes, ensuring real-time updates are sent to clients when groups are deleted. The frontend is updated to include a delete button in the DiaryView, allowing users to remove groups easily. Additionally, the groupRoutes and socketService are modified to support these new features, enhancing the overall interactivity of the application.
This commit is contained in:
Torsten Schulz (local)
2025-11-13 18:48:51 +01:00
parent 2b06a8dd10
commit 9b8dcd8561
8 changed files with 326 additions and 10 deletions

View File

@@ -58,6 +58,22 @@ class GroupService {
await group.save();
return group;
}
async deleteGroup(userToken, groupId, clubId, dateId) {
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);
}
await group.destroy();
return { success: true };
}
}
export default new GroupService();

View File

@@ -110,3 +110,13 @@ export const emitMemberChanged = (clubId) => {
emitToClub(clubId, 'member:changed', { clubId });
};
// Event für Gruppen-Änderungen (erstellen, aktualisieren, löschen)
export const emitGroupChanged = (clubId, dateId) => {
emitToClub(clubId, 'group:changed', { dateId });
};
// Event für Tournament-Änderungen (alle Aktionen)
export const emitTournamentChanged = (clubId, tournamentId) => {
emitToClub(clubId, 'tournament:changed', { tournamentId });
};