{% extends "idhub/base_admin.html" %}
{% load i18n %}

{% block content %}
<div class="row">
  <div class="col">
    <h3 class="{% if not object.is_active %}alert alert-danger{% endif %}">
      <i class="{{ icon }}"></i>
      {{ subtitle }}
    </h3>
  </div>
  <div class="col text-center">
    <a href="{% url 'idhub:admin_people_edit' object.id %}" type="button" class="btn btn-green-admin">{% trans 'Modify' %}</a>
    <a href="{% url 'idhub:admin_people_activate' object.id %}" type="button" class="btn btn-yellow ms-3 me-3">{% if object.is_active %}{% trans 'Deactivate' %}{% else %}{% trans 'Activate' %}{% endif %}</a>
    <a href="#" type="button" class="btn btn-orange" data-bs-toggle="modal" data-bs-target="#confirm-delete">{% trans 'Delete' %}</a>
  </div>
</div>
<div class="row">
  <div class="col">
    <div class="card mb-3">
      <div class="card-body">
        <div class="row border-bottom">
          <div class="col-3">
            First Name:
          </div>
          <div class="col-9 text-secondary">
            {{ object.first_name }}
          </div>
        </div>
        <div class="row border-bottom mt-3">
          <div class="col-3">
            Last Name:
          </div>
          <div class="col-9 text-secondary">
            {{ object.last_name }}
          </div>
        </div>
        <div class="row mt-3">
          <div class="col-3">
            Email:
          </div>
          <div class="col-9 text-secondary">
            {{ object.email }}
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="col text-center">
    <i class="bi bi-person-circle" style="font-size: 100px;"></i>
  </div>
</div>

<hr />

<div class="row">
  <div class="col">
    <div class="table-responsive">
      <table class="table table-striped table-sm">
        <thead>
          <tr>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Membership' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'From' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'To' %}</button></th>
          </tr>
        </thead>
        <tbody>
          {% for membership in object.memberships.all %}
          <tr>
            <td>{{ membership.get_type }}</td>
            <td>{{ membership.start_date|default:'' }}</td>
            <td>{{ membership.end_date|default:'' }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>

<div class="row mt-5">
  <div class="col">
    <div class="table-responsive">
      <table class="table table-striped table-sm">
        <thead>
          <tr>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Rol' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Description' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Service' %}</button></th>
          </tr>
        </thead>
        <tbody>
          {% for rol in object.roles.all %}
          <tr>
            <td>{{ rol.service.rol.name }}</td>
            <td>{{ rol.service.description }}</td>
            <td>{{ rol.service.domain }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
      </div>
    </div>
  </div>
</div>

<!-- Modal -->
<div class="modal" id="confirm-delete" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">{% trans 'Delete user' %} {{ object.username }}</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        {% trans 'Are you sure that you want delete this user?' %}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Clancel</button>
        <a href="{% url 'idhub:admin_people_delete' object.id %}" type="button" class="btn btn-danger">{% trans 'Delete' %}</a>
      </div>
    </div>
  </div>
</div>
{% endblock %}
