{% extends "base.j2" -%}

{%- block append_to_head_tag_section %}
  <title>My Bids &mdash; {{ shop.name }}</title>
{%- endblock %}

{% block content %}
<section class="one-column shop-offers-page">

  <div class="well">
    <h1 class="type-title">My Bids at {{ shop.name }}</h1>
    <p class="profile-meta">
      {% if active_count %}{{ active_count }} active auction{% if active_count != 1 %}s{% endif %}{% if active_count != bids|length %} of {{ bids|length }} total{% endif %}.{% else %}No active bids.{% endif %}
    </p>
  </div>

  {% if bids %}
  <div class="well">
    <table class="shop-offers-table">
      <thead>
        <tr>
          <th>Product</th>
          <th>Your bid</th>
          <th>State</th>
          <th>Ends</th>
          <th>Bid placed</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        {% for b in bids %}
        <tr class="{% if b.is_winning %}offer-row-needs-action{% elif b.is_ended %}offer-row-terminal{% endif %}">
          <td>{{ b.product_title }}</td>
          <td>${{ "%.2f"|format(b.bid_amount) }}</td>
          <td>
            <span class="offer-state-badge offer-state-{{ b.state }}">{{ b.state_human }}</span>
            {% if b.is_winning and b.is_active %}<span class="offer-row-flag">winning</span>{% elif b.is_winning %}<span class="offer-row-flag">won</span>{% endif %}
          </td>
          <td>{{ b.ends_human }}</td>
          <td>{{ b.bid_placed_human }}</td>
          <td><a href="/a/{{ b.auction_id }}" class="mps-button-small">View</a></td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
  {% else %}
  <div class="well">
    <p>You haven't placed any bids in this shop yet. Browse the shop for items on auction.</p>
    <p><a href="/" class="mps-button">Browse {{ shop.name }}</a></p>
  </div>
  {% endif %}

</section>
{% endblock %}
