diff --git a/backend/services/implementations/notificationService.ts b/backend/services/implementations/notificationService.ts index 07704608..8a470396 100644 --- a/backend/services/implementations/notificationService.ts +++ b/backend/services/implementations/notificationService.ts @@ -23,18 +23,15 @@ class NotificationService implements INotificationService { roomIds: number[], ): Promise { try { - if (roomIds.length == 0) { - throw Object.assign( - new Error('No rooms specified.'), - { code: 400 } - ); + if (roomIds.length === 0) { + throw Object.assign(new Error("No rooms specified."), { code: 400 }); } - if (roomIds.length > 1) { + if (roomIds.length > 1) { // enforces that a group can only have one member // remove in the future if the requirements change throw Object.assign( - new Error('Notification Group can only have one room.'), - { code: 400 } + new Error("Notification Group can only have one room."), + { code: 400 }, ); } const residents = await prisma.resident.findMany({ @@ -53,7 +50,7 @@ class NotificationService implements INotificationService { }, include: { recipients: true, - } + }, }); if (existingGroup && existingGroup.length > 0) { @@ -61,8 +58,10 @@ class NotificationService implements INotificationService { existingGroup.forEach((group) => { if (group.recipients.length === residentIds.length) { throw Object.assign( - new Error('Notification Group already exists with specified roomIds.'), - { code: 400 } + new Error( + "Notification Group already exists with specified roomIds.", + ), + { code: 400 }, ); } }); @@ -99,7 +98,9 @@ class NotificationService implements INotificationService { }, }); if (existingGroup && existingGroup.length > 0) { - throw 'Announcement Group already exists.'; + throw Object.assign(new Error("Announcement Group already exists."), { + code: 400, + }); } const residents = await prisma.resident.findMany({ diff --git a/frontend/src/components/pages/announcements/AnnouncementsGroups.tsx b/frontend/src/components/pages/announcements/AnnouncementsGroups.tsx index d7f9fec1..c3594e75 100644 --- a/frontend/src/components/pages/announcements/AnnouncementsGroups.tsx +++ b/frontend/src/components/pages/announcements/AnnouncementsGroups.tsx @@ -46,6 +46,8 @@ export const formatRooms = (roomIDs: number[]) => { const formattedRooms = roomIDs.map((id) => { if (id === 0) { return "New Announcement"; + } if (id === -1) { + return "All Rooms"; } return `Room ${id}`; });