{% load i18n %}
<c-ui.fab-single-action
        url="{% url 'dca_strategy_add' %}"
        hx_target="#generic-offcanvas">
</c-ui.fab-single-action>
<div class="container">
  <div class="text-3xl font-bold font-mono w-full mb-3">
    {% spaceless %}
      <div>{% translate 'Dollar Cost Average Strategies' %}</div>
    {% endspaceless %}
  </div>

  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">
    {% for strategy in strategies %}
      <div>
        <div class="card bg-base-100 card-border shadow h-full flex flex-col">
          <div class="card-header bg-base-200 p-4">
            <span class="badge badge-secondary rounded-full">{{ strategy.payment_currency.name }}</span> x <span
              class="badge badge-secondary rounded-full">{{ strategy.target_currency.name }}</span>
          </div>
          <a href="{% url 'dca_strategy_detail_index' strategy_id=strategy.id %}" hx-boost="true"
             class="no-underline card-body flex-1">
            <div class="">
              <div class="card-title text-xl">{{ strategy.name }}</div>
              <div class="text-base-content/60">{{ strategy.notes }}</div>
            </div>
          </a>
          <div class="card-footer bg-base-200 p-4 text-right cursor-pointer">
            <a class="no-underline text-base-content/60 p-1"
               role="button"
               data-tippy-content="{% translate "Edit" %}"
               hx-get="{% url 'dca_strategy_edit' strategy_id=strategy.id %}"
               hx-target="#generic-offcanvas">
              <i class="fa-solid fa-pencil fa-fw"></i>
            </a>
            <a class="text-error no-underline p-1 cursor-pointer"
               role="button"
               data-tippy-content="{% translate "Delete" %}"
               hx-delete="{% url 'dca_strategy_delete' strategy_id=strategy.id %}"
               hx-trigger='confirmed'
               data-bypass-on-ctrl="true"
               data-title="{% translate "Are you sure?" %}"
               data-text="{% translate "You won't be able to revert this!" %}"
               data-confirm-text="{% translate "Yes, delete it!" %}"
               _="install prompt_swal">
              <i class="fa-solid fa-trash fa-fw"></i>
            </a>
            {% if not strategy.owner %}
              <a class="text-primary no-underline p-1 cursor-pointer"
                 role="button"
                 data-tippy-content="{% translate "Take ownership" %}"
                 hx-get="{% url 'dca_strategy_take_ownership' strategy_id=strategy.id %}">
                <i class="fa-solid fa-crown fa-fw"></i></a>
            {% endif %}
            {% if user == strategy.owner %}
              <a class="text-primary no-underline p-1 cursor-pointer"
                 role="button"
                 hx-target="#generic-offcanvas"
                 data-tippy-content="{% translate "Share" %}"
                 hx-get="{% url 'dca_strategy_share_settings' pk=strategy.id %}">
                <i class="fa-solid fa-share fa-fw"></i></a>
            {% endif %}
          </div>
        </div>
      </div>
    {% endfor %}
  </div>
</div>
