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

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

    {% if mailbox_list %}
        <table class="table table-striped table-responsive-md btn-table">
            <thead>
            <tr>
                <th scope="col">Mailbox</th>
                <th scope="col" class="optional-column">Username</th>
                <th scope="col" class="optional-column">Domain</th>
                <th scope="col" class="optional-column">Sendonly</th>
                <th scope="col" class="optional-column">Active</th>
                <th scope="col">Actions</th>
            </tr>
            </thead>
            <tbody>

            {% for mailbox in mailbox_list %}
                <tr>
                    <th scope="row"><a href="{% url 'multimail:edit_mailbox' mailbox.id %}">{{ mailbox.username }}@{{ mailbox.domain }}</a></th>
                    <td class="optional-column">{{ mailbox.username }}</td>
                    <td class="optional-column">{{ mailbox.domain }}</td>
                    <td class="optional-column">{{ mailbox.sendonly }}</td>
                    <td class="optional-column">{{ mailbox.enabled }}</td>
                    <td><a href="{% url 'multimail:delete_mailbox' mailbox.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" colspan="4"></td>
                <td><a href="{% url 'multimail:new_mailbox' %}" class="btn btn-primary btn-sm m-0">Add Mailbox</a>
                </td>
            </tr>
            </tfoot>
        </table>
    {% else %}
        <p>You haven't set up any mailboxes yet.</p>
        <a href="{% url 'multimail:new_mailbox' %}" class="btn btn-primary btn-sm m-0">Add Mailbox</a>
    {% endif %}

{% endblock %}