Skip to content

Commit 6f90868

Browse files
committed
Fixed bugs
1 parent 1df2e73 commit 6f90868

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/components/Notifications.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const Notifications = () => {
5555
}
5656
}, [userId, notificationsSeen])
5757

58-
const markNotificationRead = async (notification) => {
58+
const markNotificationAsRead = async (notification) => {
5959
const seenBy = notification.seenBy.map((seen) => seen.id)
6060
if (!seenBy.includes(userId)) {
6161
seenBy.push(userId)
@@ -66,16 +66,16 @@ const Notifications = () => {
6666
const markAllNotificationsAsRead = () => {
6767
if (notifications) {
6868
notifications.forEach(async (notification) => {
69-
await markNotificationRead(notification)
69+
await markNotificationAsRead(notification)
7070
setNotifications([])
7171
setNotificationCount(0)
7272
setNotificationsSeen(false)
7373
})
7474
}
7575
}
7676

77-
const markNotificationAsRead = async (notification) => {
78-
await markNotificationRead(notification)
77+
const onNotificationClick = async (notification) => {
78+
await markNotificationAsRead(notification)
7979
navigate(`/${notification.link}`)
8080
}
8181

@@ -112,7 +112,7 @@ const Notifications = () => {
112112
? notifications.map((notification, key) => (
113113
<li
114114
className='dropdown-element'
115-
onClick={() => markNotificationAsRead(notification)}
115+
onClick={() => onNotificationClick(notification)}
116116
key={key}
117117
>
118118
{notification.message}

src/pages/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const Home = () => {
217217
const acceptUpdatedPolicy = async () => {
218218
const seenBy = policyUpdate.seenBy.map((seen) => seen.id)
219219
seenBy.push(userId)
220-
await userStory.updateNotifications(policyUpdate.id, seenBy)
220+
await userStory.markNotificationAsRead(policyUpdate.id, seenBy)
221221
setModal(false)
222222
}
223223

src/services/user_story.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,23 @@ const userStory = {
225225
},
226226
markNotificationAsRead: (notificationId, seenBy) => {
227227
const markNotificationAsReadQuery = {
228-
query: `mutation updateNotifications {
228+
query: `mutation updateNotifications($seenBy: [ID]) {
229229
updateUserStoryNotification(input: {
230230
where: {
231231
id: "${notificationId}"
232232
}
233233
data: {
234-
seenBy: "${seenBy}"
234+
seenBy: $seenBy
235235
}
236236
}) {
237237
userStoryNotification {
238238
id
239239
}
240240
}
241-
}`
241+
}`,
242+
variables: {
243+
seenBy: seenBy
244+
}
242245
}
243246
return apiCall('/graphql', markNotificationAsReadQuery)
244247
},

0 commit comments

Comments
 (0)