You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

49 lines
1.9 KiB

var notification = (function($, window, jQuery) {
return {
"getNotifications" : function() {
$.ajax({
url : baseurl_+"notification/get-notifications",
type : "GET",
success : function(result) {
if(result.length>0) {
notification.items = result;
$('.notif-count').text(result.length)
html=""
result.forEach(function(item) {
html+=`<li>
<a class="dropdown-item" onclick="notification.updateNotification(${item.id}, ${item.user_id})" href="javascript:void(0);">${item.first_name}, ${item.last_name}
<div class="time">${moment(item.created_at).format("hh:mm a")}</div>
<div class="date">${moment(item.created_at).format("MMM DD, YYYY")}</div>
</li></a>`
})
$('#notificationList').append(
`<ul>`+
html
+ `</ul>`
);
} else {
$('.notif-count').hide()
}
}
});
},
"updateNotification": function(notificationId,userId) {
console.log(userId)
$.ajax({
url : baseurl_+'notification/update-notification',
type : "POST",
data : {
id: notificationId,
user_id: userId
},
success : function(result) {
window.location.href = baseurl_+'subscribers_list';
}
})
}
}
})(jQuery, this);
$(function(){
notification.getNotifications();
});