{% extends "base.html" %}
{% load static %}
{% load django_bootstrap5 %}

{% block title %}BMA Settings{% endblock title %}

{% block main_content %}
  <div class="row">
    <table class="table">
      <tbody>
        <tr>
          <th>BornHack Username</th>
          <td>{{ user.username }}</td>
        </tr>
        <tr>
          <th>BMA UUID</th>
          <td>{{ user.pk }}</td>
        </tr>
        <tr>
          <th>BMA Handle</th>
          <td>{{ user.handle }}</td>
        </tr>
        <tr>
          <th>BMA Member Since</th>
          <td>{{ user.created_at }}</td>
        </tr>
        <tr>
          <th>Description</th>
          <td>
            {{ user.description|default:"N/A" }}
          </td>
        </tr>
        <tr>
          <th>API Clients</th>
          <td>
            <table class="table table-sm table-borderless">
              <thead>
                <tr>
                  <th>Name</th>
                  <th>Access Tokens</th>
                </tr>
              </thead>
              <tbody>
                {% for client in request.user.oauth2_provider_application.all %}
                <tr>
                  <td>{{ client.name }}</td>
                  <td>{{ client.accesstoken_set.count }}</td>
                </tr>
                {% endfor %}
              </tbody>
            </table>
          </td>
        </tr>
      </tbody>
    </table>
    <a href="{% url 'user_settings_update' %}" class="btn btn-primary"><i class="fas fa-edit"></i> Update</a>
  </div>
{% endblock main_content %}
