{% extends "base.j2" -%}

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

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

  <div class="well">
    <h1 class="type-title">My Offers at {{ shop.name }}</h1>
    <p class="profile-meta">
      {% if open_count %}{{ open_count }} open{% if open_count != offers|length %} of {{ offers|length }} total{% endif %}.{% else %}No open offers.{% endif %}
    </p>
  </div>

  {% if offers %}
  <div class="well">
    <table class="shop-offers-table">
      <thead>
        <tr>
          <th>Product</th>
          <th>Your offer</th>
          <th>Round</th>
          <th>State</th>
          <th>Last action</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        {% for o in offers %}
        <tr class="{% if o.waiting_on_buyer %}offer-row-needs-action{% elif o.is_terminal %}offer-row-terminal{% endif %}">
          <td>{{ o.product_title }}</td>
          <td>${{ "%.2f"|format(o.current_amount) }}</td>
          <td>{{ o.round_count }}</td>
          <td>
            <span class="offer-state-badge offer-state-{{ o.state }}">{{ o.state_human }}</span>
            {% if o.waiting_on_buyer %}<span class="offer-row-flag">your turn</span>{% endif %}
          </td>
          <td>{{ o.last_action_human }}</td>
          <td><a href="/o/{{ o.id }}" class="mps-button-small">View</a></td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
  {% else %}
  <div class="well">
    <p>You haven't made any offers in this shop yet. When you do, every negotiation shows up here.</p>
    <p><a href="/" class="mps-button">Browse {{ shop.name }}</a></p>
  </div>
  {% endif %}

</section>
{% endblock %}
