<%# NB this template is rendered both in the notification navbar %>
<%# and on notifications#index                                   %>
<% cache ['index-notification', notification] do %>
  <% present notification do |presenter| %>
    <li class="notification <%= notification.read? ? '' : 'unread' %>" data-notification-id="<%= notification.id %>">

      <div class="details">
        <%= presenter.avatar_with_link(40) %>
      </div>

      <div class="body">

        <div class="title">
          <%= presenter.render_title %>
        </div>

        <div class="time">
          <%= presenter.created_at_ago %>
        </div>

      </div>
      <%= presenter.icon %>

      <% if !notification.read? %>
        <%= link_to notification_path(notification),
                    title: 'Mark as read',
                    class: 'notification-read',
                    data: { behavior: 'notification-read' },
                    remote: true,
                    method: :put do %>
          <i class="fa-regular fa-check-circle" aria-hidden="true"><span class="visually-hidden">Mark as read</span></i>
        <% end %>
      <% end %>
    </li>
  <% end %>
<% end %>
