loadTicketCounts();
function loadTicketCounts() {
        var userObj = JSON.parse(localStorage.getItem('userObj'));


    // var url = serverURL + "tickets?page=0&size=10000000&sort=createdAt,desc";
    var url = serverURL + "tickets/assignee/"+userObj.id+"?page=0&size=10000000&sort=createdAt,desc";
    $.ajax({
        url: url,
        type: 'GET',
        dataType: "json",
        headers: {
            Authorization: "Bearer " + userObj.accessToken,
            "Content-Type": "application/json"
        },
        success: function (response) {

            let notifications = response.content || [];

            // 🔴 Count unread
            let unreadCount = notifications.filter(n => !n.read).length;
            console.log("Unread Tickets:", unreadCount);
            $(".badge_tickets_counts").text(unreadCount);
             $(".header-badge").text(unreadCount).toggleClass('has-notifications', unreadCount > 0);



        },
        error: function () {
            
            
        }
    });
}

