{% extends 'multimail/page.html' %}

{% block content %}
    <h1 class="mt-4">Aliases</h1>

    {% if alias_list %}
        <table class="table table-striped btn-table">
            <thead>
            <tr>
                <th scope="col">Source
                <span class="optional-column-replacement">/ Destination</span>
                </th>
                <th scope="col" class="optional-column">Destination</th>
                <th scope="col">Actions</th>
            </tr>
            </thead>
            <tbody>

            {% for alias in alias_list %}
                <tr>
                    <th scope="row"><a
                            href="{% url 'multimail:edit_alias' alias.id %}">{{ alias.source_username }}@{{ alias.source_domain }}</a>
                        <span class="optional-column-replacement">{{ alias.destination_username }}@{{ alias.destination_domain }}</span>
                    </th>
                    <th scope="row" class="optional-column">{{ alias.destination_username }}@{{ alias.destination_domain }}</th>
                    <td><a href="{% url 'multimail:delete_alias' alias.id %}"
                           class="btn btn-danger btn-sm m-0">Delete</a></td>
                </tr>
            {% endfor %}

            </tbody>
            <tfoot>
            <tr>
                <th scope="row">
                </th>
                <td class="optional-column"></td>
                <td><a href="{% url 'multimail:new_alias' %}" class="btn btn-primary btn-sm m-0">Add Alias</a>
                </td>
            </tr>
            </tfoot>
        </table>
    {% else %}
        <p>You haven't set up any aliases yet.</p>
        <a href="{% url 'multimail:new_alias' %}" class="btn btn-primary btn-sm m-0">Add Alias</a>
    {% endif %}

{% endblock %}