{% extends "common/base.html" %}
{% load i18n %}
{% load purchase %}
{% block content %}
    <h1>{% translate "Baskets" %}</h1>
    <div class="row row-cols-2 row-cols-xl-6 row-cols-lg-5 row-cols-md-4 row-cols-sm-3 g-4">
        {% for basket in baskets %}
            <div class="col">
                <div class="card h-100">
                    <div class="card-body">
                        <h5 class="card-title">{% blocktranslate with basket_id=basket.id %}Basket #{{ basket_id }}{% endblocktranslate %}</h5>
                        <p class="card-text">
                            {% blocktranslate count counter=basket.articles_count %}1 item{% plural %}{{ counter }} items{% endblocktranslate %}<br>
                            {{ basket.price|currency }}<br>
                            {{ basket.payment_method|default:"-" }}<br>
                            {% now "Y-m-d" as todays_date %}
                            {% if basket.created_at|date:"Y-m-d" == todays_date %}
                                {{ basket.created_at|date:"TIME_FORMAT" }}
                            {% else %}
                                {{ basket.created_at }}
                            {% endif %}
                        </p>
                        <div class="btn-group btn-group-sm">
                            {% if perms.purchase.change_basket %}
                                <a href="{% url "purchase:update" basket.id %}" class="btn btn-primary"><i class="fa-solid fa-pen-to-square"></i></a>
                            {% endif %}
                            {% if perms.purchase.delete_basket %}
                                <a href="{% url "purchase:delete" basket.id %}" class="btn btn-danger"><i class="fa-solid fa-trash"></i></a>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        {% endfor %}
    </div>
{% endblock %}
