-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migrations, integrate APIs with residents, and integrate some fro…
…ntend
- Loading branch information
1 parent
04d474c
commit 311fb11
Showing
7 changed files
with
358 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 51 additions & 33 deletions
84
frontend/src/APIClients/Mutations/NotificationMutations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,76 @@ | ||
import { gql } from "@apollo/client"; | ||
|
||
export const SEND_NOTIFICATION = gql` | ||
mutation SendNotification( | ||
$authorId: ID! | ||
$title: String! | ||
$message: String! | ||
$recipientIds: [ID!] | ||
) { | ||
sendNotification( | ||
authorId: $authorId | ||
title: $title | ||
message: $message | ||
recipientIds: $recipientIds | ||
) { | ||
export const CREATE_NOTIFICATION_GROUP = gql` | ||
mutation CreateNotificationGroup($roomIds: [Int!]) { | ||
createNotificationGroup(roomIds: $roomIds) { | ||
id | ||
authorId | ||
title | ||
message | ||
createdAt | ||
announcementGroup | ||
} | ||
} | ||
`; | ||
|
||
export const DELETE_USER_NOTIFICATION = gql` | ||
mutation DeleteUserNotification($notificationId: ID!) { | ||
deleteUserNotification(notificationId: $notificationId) { | ||
export const CREATE_ANNOUNCEMENT_GROUP = gql` | ||
mutation CreateAnnouncementGroup { | ||
createAnnouncementGroup { | ||
id | ||
announcementGroup | ||
} | ||
} | ||
`; | ||
|
||
export const SEND_NOTIFICATION_TO_GROUP = gql` | ||
mutation SendNotificationToGroup( | ||
$groupId: ID! | ||
$notification: CreateNotificationDTO! | ||
) { | ||
sendNotificationToGroup(groupId: $groupId, notification: $notification) { | ||
id | ||
authorId | ||
title | ||
message | ||
createdAt | ||
authorId | ||
} | ||
} | ||
`; | ||
|
||
export const UPDATE_SEEN_NOTIFICATION = gql` | ||
mutation UpdateSeenNotification($notificationId: ID!) { | ||
updateSeenNotification(notificationId: $notificationId) { | ||
export const DELETE_NOTIFICATION_GROUP = gql` | ||
mutation DeleteNotificationGroup($groupId: ID!) { | ||
deleteNotificationGroup(groupId: $groupId) { | ||
id | ||
notificationId | ||
recipientId | ||
seen | ||
announcementGroup | ||
} | ||
} | ||
`; | ||
|
||
export const SEND_ANNOUNCEMENT = gql` | ||
mutation SendAnnouncement($title: String, $message: String, $userId: ID) { | ||
sendAnnouncement(title: $title, message: $message, userId: $userId) { | ||
export const UPDATE_NOTIFICATION_BY_ID = gql` | ||
mutation UpdateNotificationById( | ||
$notificationId: ID! | ||
$notification: UpdateNotificationDTO! | ||
) { | ||
updateNotificationById( | ||
notificationId: $notificationId | ||
notification: $notification | ||
) { | ||
id | ||
authorId | ||
title | ||
message | ||
createdAt | ||
authorId | ||
} | ||
} | ||
`; | ||
|
||
export const DELETE_NOTIFICATION_BY_IDS = gql` | ||
mutation DeleteNotificationByIds($notificationIds: [ID!]) { | ||
deleteNotificationByIds(notificationIds: $notificationIds) | ||
} | ||
`; | ||
|
||
export const UPDATE_SEEN_NOTIFICATION = gql` | ||
mutation UpdateSeenNotification($notificationSeenId: ID!) { | ||
updateSeenNotification(notificationSeenId: $notificationSeenId) { | ||
id | ||
notificationId | ||
recipientId | ||
seen | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,61 @@ | ||
import { gql } from "@apollo/client"; | ||
|
||
export const GET_NOTIFICATIONS_BY_USER_ID = gql` | ||
query GetNotificationsByUserId($userId: ID!) { | ||
getNotificationsByUserId(userId: $userId) { | ||
export const GET_NOTIFICATIONS_BY_IDS = gql` | ||
query getNotificationsByIds($notificationIds: [ID!]) { | ||
getNotificationsByIds(notificationIds: $notificationIds) { | ||
id | ||
notificationId | ||
recipientId | ||
seen | ||
notification { | ||
id | ||
message | ||
createdAt | ||
authorId | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export const GET_NOTIFCATION_BY_ID = gql` | ||
query GetNotificationById($id: ID!) { | ||
getNotificationById(id: $id) { | ||
export const GET_NOTIFCATION_BY_RESIDENT = gql` | ||
query getNotificationByResident($residentId: ID!) { | ||
getNotificationByResident(residentId: $id) { | ||
id | ||
notificationId | ||
recipientId | ||
seen | ||
notification { | ||
id | ||
message | ||
createdAt | ||
authorId | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export const GET_ALL_GROUPS_AND_NOTIFICATIONS = gql` | ||
query getAllGroupsAndNotifications { | ||
getAllGroupsAndNotifications { | ||
id | ||
announcementGroup | ||
notifications { | ||
id | ||
message | ||
createdAt | ||
authorId | ||
} | ||
recipients { | ||
userId | ||
residentId | ||
displayName | ||
profilePictureURL | ||
isActive | ||
roomNumber | ||
credits | ||
dateJoined | ||
dateLeft | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
export type NotificationResponse = { | ||
id: string; | ||
message: string; | ||
createdAt?: Date; | ||
authorId?: string; | ||
title: string; | ||
recipients?: NotificationReceivedResponse[]; | ||
}; | ||
|
||
export type NotificationCreateRequest = { | ||
message: string; | ||
createdAt: Date; | ||
recipients?: [NotificationReceived]; | ||
createdAt?: Date; | ||
authorId?: string; | ||
}; | ||
|
||
export type NotificationUpdateRequest = { | ||
message?: string; | ||
createdAt?: Date; | ||
authorId?: string; | ||
}; | ||
|
||
export type NotificationGroupResponse = { | ||
id: string; | ||
// recipients?: Residentesponse[]; TODO: add when resident response exists | ||
notifications?: NotificationResponse[]; | ||
announcementGroup: boolean; | ||
}; | ||
|
||
export type NotificationReceived = { | ||
export type NotificationReceivedResponse = { | ||
id: string; | ||
notificationId: string; | ||
notification?: NotificationResponse; | ||
recipientId: number; | ||
seen: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.