{% extends 'layouts/app.html' %}

{% block title %}Account settings{% endblock %}

{% block body %}
  <div class="row">
    <div class="col-md-5">
      <h2>Settings</h2>
      <h4 class="text-muted margin-bottom">{{ current_user.email }}</h4>

      <div class="list-group">
        <a href="{{ url_for('user.update_credentials') }}"
           class="list-group-item">
          Update email and password
        </a>
        {% if current_user.username %}
          <span class="list-group-item quarter-faded text-muted">
            Your username is
            <strong>{{ current_user.username }}</strong>
          </span>
        {% else %}
          <a href="{{ url_for('user.welcome') }}"
             class="list-group-item">
            Pick a username
          </a>
        {% endif %}
      </div>

      <h2>Betting</h2>
      <div class="list-group">
        <a href="{{ url_for('bet.history') }}" class="list-group-item">
          Betting history
        </a>
        <span class="list-group-item quarter-faded text-warning">
          You have
          <strong>{{ current_user.coins }}</strong> coins
        </span>
      </div>
      <a href="#coming-soon"
         class="btn btn-primary">Buy more coins</a>
    </div>
    <div class="col-md-5 col-md-push-1 col-md-offset-1">
      {% if current_user.subscription %}
        <h2>{{ current_user.subscription.plan | title }}
          subscription</h2>
        <h4 class="text-muted margin-bottom">
          {{ current_user.credit_card.brand }}
          ****{{ current_user.credit_card.last4 }}
          ({{ current_user.credit_card.exp_date.strftime('%m/%Y') }})
        </h4>

        <div class="list-group">
          <a class="list-group-item"
             href="{{ url_for('billing.update_payment_method') }}">
            Update payment info
          </a>
          <a class="list-group-item"
             href="{{ url_for('billing.billing_details') }}">
            Billing details
          </a>
          <a class="list-group-item"
             href="{{ url_for('billing.update') }}">
            Change plan
          </a>
          <a class="list-group-item"
             href="{{ url_for('billing.cancel') }}">
            <span class="text-muted">Cancel subscription</span>
          </a>
        </div>
      {% else %}
        <h2>Subscribe today</h2>
        <h4 class="text-muted">
          Hey buddy, why aren't you subscribed?
        </h4>

        <p>
          Now that you've created an account, wouldn't it be unbelievably
          amazing to unlock everything by becoming a subscriber today?
        </p>
        <a href="{{ url_for('billing.pricing') }}"
           class="btn btn-primary">Learn more</a>

        <hr/>
        {% if current_user.invoices %}
          <h3>Previous subscription info</h3>
          <div class="list-group">
            <a class="list-group-item"
              href="{{ url_for('billing.billing_details') }}">
              Billing details
            </a>
          </div>
        {% endif %}
      {% endif %}
    </div>
  </div>
{% endblock %}
