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:
@@ -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();
|
||||
@@ -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 });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user