-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotificationFollow.js
26 lines (26 loc) · 1.06 KB
/
notificationFollow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export default function initializeNotificationFollow(projectId) {
//region follow/unfollow notifications for this project
document.querySelector('#bell-icon').addEventListener('click', function() {
fetch('./api/notifications/follow.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
project_id: projectId
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Toggle bell icon color
this.classList.toggle('text-success');
this.classList.toggle('text-danger');
const followStatus = document.querySelector('#followStatus');
followStatus.innerText = data.message;
}
})
.catch(error => console.error('Error:', error));
});
//endregion follow/unfollow notifications for this project
}