{% extends "oscar/customer/baseaccountpage.html" %}
{% load i18n %}

{% block tabcontent %}
    {% if not alerts %}
        <p>{% trans "You do not have any active alerts for out-of-stock products." %}</p>
    {% else %}
        <form method="post" id="alerts_form">
            {% csrf_token %}
            <table class="table table-striped table-bordered">
                <tr>
                    <th>{% trans "Product" %}</th>
                    <th>{% trans "Status" %}</th>
                    <th>{% trans "Date created" %}</th>
                    <th></th>
                </tr>

                {% for alert in alerts %}
                    <tr>
                        <td>
                            {% with product=alert.product %}
                                {% if product.is_public %}
                                    <a href="{{ product.get_absolute_url }}">{{ product.get_title }}</a>
                                {% else %}
                                    {{ product.get_title }}
                                {% endif %}
                            {% endwith %}
                        </td>
                        <td>{{ alert.status }}</td>
                        <td>{{ alert.date_created }}</td>
                        <td>
                            {% if alert.can_be_cancelled %}
                                <a href="{% url 'customer:alerts-cancel-by-pk' pk=alert.pk %}?next={% url 'customer:alerts-list' %}" class="btn btn-danger">{% trans "Cancel" %}</a>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
            </table>
            {% include "oscar/partials/pagination.html" %}
        </form>
    {% endif %}

{% endblock tabcontent %}
