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

{% block tabcontent %}

    {% if addresses %}
        <table class="table table-striped table-bordered">
            <tbody>
                <tr>
                    <th>{% trans 'Address' %}</th>
                    <th></th>
                </tr>
                {% for address in addresses %}
                    <tr>
                        <td>
                            {% if address.is_default_for_shipping %}
                                <span class="badge badge-success">{% trans 'Default shipping address' %}</span>
                            {% endif %}
                            {% if address.is_default_for_billing %}
                                <span class="badge badge-info">{% trans 'Default billing address' %}</span>
                            {% endif %}
                            <address>
                                {% for field in address.active_address_fields %}
                                    {{ field }}<br/>
                                {% endfor %}
                            </address>
                        </td>
                        <td>
                            <div class="btn-group">
                                <a class="btn btn-secondary" href="{% url 'customer:address-detail' pk=address.id %}">{% trans 'Edit' %}</a>
                                <button class="btn btn-secondary dropdown-toggle" data-toggle="dropdown"></button>
                                <div class="dropdown-menu">
                                    <a href="{% url 'customer:address-delete' pk=address.id %}" class="dropdown-item">
                                        {% trans 'Delete' %}
                                    </a>
                                    {% if address.country.is_shipping_country and not address.is_default_for_shipping %}
                                        <a href="{% url 'customer:address-change-status' pk=address.id action='default_for_shipping' %}" class="dropdown-item">
                                            {% trans 'Set as default shipping address' %}
                                        </a>
                                    {% endif %}
                                    {% if not address.is_default_for_billing %}
                                        <a href="{% url 'customer:address-change-status' pk=address.id action='default_for_billing' %}" class="dropdown-item">
                                            {% trans 'Set as default billing address' %}
                                        </a>
                                    {% endif %}
                                </div>
                            </div>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
        {% include "oscar/partials/pagination.html" %}
    {% else %}
        <p>{% trans 'There are no addresses in your address book.' %}</p>
    {% endif %}
    <p>
        <a href="{% url 'customer:address-create' %}" class="btn btn-primary">{% trans 'Add a new address' %}</a>
    </p>
{% endblock tabcontent %}
