{% load i18n %}
<div class="card bg-base-100 shadow-xl">
  <div class="card-body">
    <div id="quick-transactions-table">
      {% if quick_transactions %}
        <c-config.search></c-config.search>

        <div class="overflow-x-auto">
          <table class="table table-zebra">
            <thead>
            <tr>
              <th scope="col" class="table-col-auto"></th>
              <th scope="col">{% translate 'Name' %}</th>
              <th scope="col">{% translate 'Account' %}</th>
              <th scope="col">{% translate 'Amount' %}</th>
            </tr>
            </thead>
            <tbody>
            {% for qt in quick_transactions %}
              <tr class="recurring_transaction">
                <td class="table-col-auto text-center">
                  <div class="join" role="group" aria-label="{% translate 'Actions' %}">
                    <a class="btn btn-secondary btn-sm join-item"
                       role="button"
                       data-tippy-content="{% translate "Edit" %}"
                       hx-get="{% url 'quick_transaction_edit' quick_transaction_id=qt.id %}"
                       hx-swap="innerHTML"
                       hx-target="#generic-offcanvas">
                      <i class="fa-solid fa-pencil fa-fw"></i></a>
                    <a class="btn btn-error btn-sm join-item"
                       role="button"
                       data-tippy-content="{% translate "Delete" %}"
                       hx-delete="{% url 'quick_transaction_delete' quick_transaction_id=qt.id %}"
                       hx-trigger='confirmed'
                       hx-swap="innerHTML"
                       data-bypass-on-ctrl="true"
                       data-title="{% translate "Are you sure?" %}"
                       data-text="{% translate "This will delete this item" %}"
                       data-confirm-text="{% translate "Yes, delete it!" %}"
                       _="install prompt_swal"><i class="fa-solid fa-trash fa-fw"></i></a>
                  </div>
                </td>
                <td>
                  <div
                      class="{% if qt.type == 'EX' %}text-error{% else %}text-success{% endif %}">
                    {{ qt.name }}
                  </div>
                </td>
                <td>
                  {% if qt.account.group %}{{ qt.account.group }} • {% endif %}{{ qt.account }}
                </td>
                <td>
                  <c-amount.display
                    :amount="qt.amount"
                    :prefix="qt.account.currency.prefix"
                    :suffix="qt.account.currency.suffix"
                    :decimal_places="qt.account.currency.decimal_places"
                    color="{% if qt.type == "EX" %}red{% else %}green{% endif %}"></c-amount.display>
                </td>
              </tr>
            {% endfor %}
            </tbody>
          </table>
        </div>
      {% else %}
        <c-msg.empty title="{% translate "Nothing to see here..." %}" remove-padding></c-msg.empty>
      {% endif %}
    </div>
  </div>
</div>
