{% extends 'dashboard.html' %}
{% load static %}

{% block head_title %}{{ customer.get_full_name }} | {% endblock %}

{% block content %}
<article>
    <p>
        <a href="{% url 'dashboard:customer-list' %}">&larr; Back to customers</a>
    </p>
    <header class="object-header">
        <h1><img src="{% static "images/customer.png" %}"> Customer: {{customer.get_full_name}}</h1>
        {% if perms.core.change_customer %}
        <a href="{% url 'dashboard:customer-update' customer.pk %}" class="btn">Edit</a>
        {% endif %}
    </header>
    <section class="panel">
        <header class="panel-header">
            <h4>Details</h4>
        </header>
        <dl class="panel-datalist">
            <dt>Primary email address</dt>
            <dd>
                <a href="mailto:{{ customer.email }}">{{ customer.email }} &nearr;</a>
            </dd>

            <dt>Default shipping address</dt>
            <dd>
                {% include 'dashboard/partials/_address.html' with address=customer.default_shipping_address %}
            </dd>

            <dt>All addresses</dt>
            <dd>
            {% for address in customer.addresses.all  %}
                {% include 'dashboard/partials/_address.html' with address=address %}
            {% endfor %}
            </dd>
        </dl>
    </section>
    
    <section class="panel">
        <header class="panel-header">
            <h4>Orders</h4>
        </header>
        <table>
            {% include 'dashboard/order/_table.html' with order_list=customer.orders.all %}
        </table>
    </section>
</article>
{% endblock content %}
