{% load i18n %}
<table class="table table-striped align-middle">
    <thead><tr>
        <th></th><th data-sort="text" data-sort-default="asc">{% trans "Name" %}</th>
        <th data-sort="num">{% trans "Stock" %}</th><th data-sort="num">{% trans "Price" %}</th><th></th>
    </tr></thead>
    <tbody>
    {% for listing in listings %}
        <tr data-name="{{ listing.eve_type.name|lower }}">
            <td class="text-nowrap">
                <img src="https://images.evetech.net/types/{{ listing.eve_type.id }}/icon?size=32" alt="" width="32" height="32">
                {% include 'shop/_featured_star.html' %}
            </td>
            <td>{{ listing.eve_type.name }}</td>
            <td data-sort-value="{{ listing.stock }}">{{ listing.stock }}</td>
            <td data-sort-value="{{ listing.price }}">{{ listing.price_display }} <span class="badge bg-secondary">{{ listing.price_mode_display }}</span></td>
            <td class="text-end">
                <button type="button" class="btn btn-sm btn-outline-theme edit-module-btn"
                        data-url="{% url 'backoffice:edit_module' shop.pk listing.pk %}"
                        data-name="{{ listing.eve_type.name }}"
                        data-price-mode="{{ listing.price_mode }}"
                        data-price="{{ listing.price }}"
                        data-price-pct="{{ listing.price_pct|default_if_none:'' }}">
                    <i class="fa-solid fa-pen-to-square fa-fw"></i> {% trans "Edit" %}
                </button>
                <form method="post" action="{% url 'backoffice:remove_module' shop.pk listing.pk %}" class="d-inline">
                    {% csrf_token %}
                    <button class="btn btn-sm btn-outline-danger">{% trans "Remove" %}</button>
                </form>
            </td>
        </tr>
    {% empty %}
        <tr><td colspan="5" class="text-muted">{% trans "No modules listed yet." %}</td></tr>
    {% endfor %}
    </tbody>
</table>
