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

{% block head_title %}Site Configuration | {% endblock %}

{% block content %}
<article>
    <header class="object-header">
        <h1><img src="{% static 'images/gear.png' %}"> Site configuration</h1>
    </header>

    <section class="panel">
        <header class="panel-header">
            <h4>Site Settings</h4>
            {% if perms.core.change_sitesettings %}
            <a href="{% url 'dashboard:settings-update' site_settings.pk %}" class="btn">Edit</a>
            {% endif %}
        </header>
        <dl class="panel-datalist">
            <dt>USPS User ID</dt>
            <dd>{{ site_settings.usps_user_id }}</dd>
            <dt>Default shipping rate</dt>
            <dd>{{ site_settings.default_shipping_rate }}</dd>
            <dt>Free shipping min</dt>
            <dd>${{ site_settings.free_shipping_min }}</dd>
            <dt>Max cart quantity</dt>
            <dd>{{ site_settings.max_cart_quantity }} items</dd>
            <dt>Max cart weight</dt>
            <dd>{{ site_settings.max_cart_weight }}</dd>
            <dt>Default contact email</dt>
            <dd>{{ site_settings.default_contact_email }}</dd>
            <dt>Default order-from email</dt>
            <dd>{{ site_settings.order_from_email }}</dd>
        </dl>
    </section>

    <section class="panel">
        <header class="panel-header">
            <h4>Shipping rates</h4>
            <a href="{% url 'dashboard:rate-create' %}" class="btn">+ New rate</a>
        </header>
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Shipping Provider</th>
                    <th>Container</th>
                    <th>Weight range</th>
                </tr>
            </thead>
            <tbody>
                {% for rate in shipping_rate_list %}
                <tr class="is-link" onclick="window.location='{% url 'dashboard:rate-detail' rate.pk %}'">
                    <td>{{ rate }}</td>
                    <td>{{ rate.shipping_provider }}</td>
                    <td>{{ rate.get_container_display }}</td>
                    <td>{{ rate.min_order_weight }} &ndash; {{ rate.max_order_weight }}</td>
                </tr>
                {% empty %}
                    <p>No shipping rates yet.</p>
                {% endfor %}
            </tbody>
        </table>
    </section>
</article>
{% endblock %}
