{% extends 'base.html' %}

{% block title %}Your alerts - Packs Site{% endblock %}

{% block content %}
<div class="home-section-header">
    <h1><i class="fas fa-bell"></i> Your alerts</h1>
    <form method="post" action="{% url 'announcements:mark_all_read' %}">
        {% csrf_token %}
        <input type="hidden" name="next" value="{{ request.path }}">
        <button type="submit" class="btn btn-secondary"><i class="fas fa-check-double"></i> Mark all read</button>
    </form>
</div>

<div class="card">
    <ul class="notify-list">
        {% for n in page %}
            <li class="notify-item{% if not n.read %} notify-unread{% endif %}">
                <a href="{% url 'library:project_detail' n.project.slug %}">{{ n.text }}</a>
                <span class="announce-meta">{{ n.created_at|timesince }} ago{% if not n.read %} · <span class="notify-new">new</span>{% endif %}</span>
            </li>
        {% empty %}
            <li class="empty-hint">You have no alerts yet.</li>
        {% endfor %}
    </ul>
</div>

{% if page.has_other_pages %}
    <div class="pagination">
        {% if page.has_previous %}
            <a href="?page={{ page.previous_page_number }}">&laquo;</a>
        {% endif %}
        <span>Page {{ page.number }} of {{ page.paginator.num_pages }}</span>
        {% if page.has_next %}
            <a href="?page={{ page.next_page_number }}">&raquo;</a>
        {% endif %}
    </div>
{% endif %}
{% endblock %}
