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

{% block content %}
<article>
    <header class="object__header">
        <h1><img src="{% static "images/box.png" %}" alt=""> Orders</h1>
    </header>
    <section class="object__list">
        <div class="object__item panel__header object__item--col5" href="order-detail">
            <span>Order #</span>
            <span>Date</span>
            <span>Customer</span>
            <span>Status</span>
            <span>Total</span>
        </div>
    {% for order in order_list  %}
        <a class="object__item object__item--link object__item--col5" href="{% url 'dashboard:order-detail' order.pk %}">
            <span>#{{order.pk}}</span>
            <span>{{order.created_at|date:"D, M j Y"}}</span>
            <span>{{order.customer.get_full_name}}</span>
            <span class="order__status--display">
                <div class="status__dot order__status--{{order.status}}"></div>
                {{order.get_status_display}}</span>
            <span>${{order.get_total_price_after_discount}}</span>
        </a>
    {% empty %}
        <span class="object__item">No orders</span>
    {% endfor %}
    </section>
    <section>
        <div class="pagination">
            <p class="step-links">
                {% if page_obj.has_previous %}
                    <a href="?page=1">&laquo; first</a>
                    <a href="?page={{ page_obj.previous_page_number }}">previous</a>
                {% endif %}

                <span class="current">
                    Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
                </span>

                {% if page_obj.has_next %}
                    <a href="?page={{ page_obj.next_page_number }}">next</a>
                    <a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a>
                {% endif %}
            </p>
        </div>
    </section>
</article>
{% endblock content %}
