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

{% block tabcontent %}
<div class="row">
{% if addresses %}
{% for address in addresses %}
<div class="col-lg-6">
    <div class="tabcontent-item tabcontent-even address-line">
        <div class="tabcontent-item-body">
            {% block address_title %}
            {% if address.is_default_for_shipping %}
            <span class="label label-success"><b>{% trans 'Shipping address' %}</b></span>
            {% endif %}
            {% if address.is_default_for_billing %}
            <span class="label label-info"><b>{% trans 'Billing address' %}</b></span>
            {% endif %}
            {% endblock address_title %}
            <table class="table table-borderless table-sm">
                <tbody>
                    {% block address_details %}
                    <tr>
                        <td>{% trans "Name" %}:</td>
                        <td>{{ address.first_name }} {{ address.last_name }}</td>
                    </tr>
                    <tr>
                        <td>{% trans "Address" %}:</td>
                        <td>{{ address.line1 }} {{ address.house_number }}</td>
                    </tr>
                    <tr>
                        <td>{% trans "Post/Zip-code" %}:</td>
                        <td>{{ address.postcode }}</td>
                    </tr>
                    <tr>
                        <td>{% trans "Phone number" %}:</td>
                        <td>{{ address.phone_number }}</td>
                    </tr>
                    {% endblock address_details %}
                </tbody>
            </table>
        </div>

        <div class="tabcontent-item-footer">
            <div class="dropdown btn-dropdown">
                <button class="btn btn-primary dropdown-toggle no-caret icon-left" data-bs-toggle="dropdown">
                    <i class="fa fa-cog-solid"></i> {% trans "Options" %}
                </button>
                <ul class="dropdown-menu">
                    <li>
                        <a class="dropdown-item" href="{% url 'customer:address-detail' pk=address.id %}">{% trans "Edit" %}</a>
                    </li>
                    <li>
                        <a class="dropdown-item" href="{% url 'customer:address-delete' pk=address.id %}">
                            {% trans 'Delete' %}
                        </a>
                    </li>

                    {% if address.country.is_shipping_country and not address.is_default_for_shipping %}
                    <li>
                        <a class="dropdown-item" href="{% url 'customer:address-change-status' pk=address.id action='default_for_shipping' %}">
                            {% trans 'Set as default shipping address' %}
                        </a>
                    </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </div>
</div>
{% endfor %}
{% else %}
<p>{% trans 'There are no addresses in your address book.' %}</p>
{% endif %}
</div>
{% include "oscar/partials/pagination.html" %}
{% block new_address %}
<p>
    <a href="{% url 'customer:address-create' %}" class="btn btn-primary">{% trans 'Add a new address' %}</a>
</p>
{% endblock new_address %}
{% endblock tabcontent %}
