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

{% block content %}
<div class="row">
  <div class="col">
    <h3>
      <i class="{{ icon }}"></i>
      {{ subtitle }}
    </h3>
  </div>
  <div class="col text-end">
    {% if object.get_status == 'Issued' %}
    <a class="btn btn-yellow" class="btn btn-orange" data-bs-toggle="modal" data-bs-target="#confirm-revoke" href="javascript:void()">{% trans 'Revoke' %}</a>
    <a class="btn btn-orange" class="btn btn-orange" data-bs-toggle="modal" data-bs-target="#confirm-delete" href="javascript:void()">{% trans 'Delete' %}</a>
    {% endif %}
    {% if object.get_status == 'Revoked' %}
    <a class="btn btn-orange" class="btn btn-orange" data-bs-toggle="modal" data-bs-target="#confirm-delete" href="javascript:void()">{% trans 'Delete' %}</a>
    {% endif %}
  </div>
</div>
<div class="row">
  <div class="col-3">
  </div>
  <div class="col">
    {% for k, v in object.get_datas %}
    <div class="row mt-3">
      <div class="col-3 text-end">
      <strong>{{ k|capfirst }}:</strong>
      </div>
      <div class="col bg-light text-secondary">
        {{ v }}
      </div>
    </div>
    {% endfor %}
    <div class="row mt-3">
      <div class="col-3 text-end">
      <strong>{% trans 'Issuance date' %}:</strong>
      </div>
      <div class="col bg-light text-secondary">
        {{ object.issuer_on|default_if_none:"" }}
      </div>
    </div>
    <div class="row mt-3">
      <div class="col-3 text-end">
      <strong>{% trans 'Status' %}:</strong>
      </div>
      <div class="col bg-light text-secondary">
        {{ object.get_status}}
      </div>
    </div>
    <div class="row mt-3">
      <div class="col text-center">
        <a class="btn btn-green-admin" href="{% url 'idhub:admin_credential_json' object.id %}">{% trans 'View in JSON format' %}</a>
      </div>
    </div>
  </div>
</div>
<!-- Modal Revoke -->
<div class="modal" id="confirm-revoke" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">{% trans 'Revoke credential' %} {{ object.get_type }}</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 revoke this credential?' %}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'Cancel' %}</button>
        <a href="{% url 'idhub:admin_credentials_revoke' object.id %}" type="button" class="btn btn-danger">{% trans 'Revoke' %}</a>
      </div>
    </div>
  </div>
</div>
<!-- Modal Delete -->
<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">{% trans 'Delete credential' %} {{ object.get_type }}</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 Credential?' %}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'Cancel' %}</button>
        <a href="{% url 'idhub:admin_credentials_delete' object.id %}" type="button" class="btn btn-danger">{% trans 'Delete' %}</a>
      </div>
    </div>
  </div>
</div>
{% endblock %}
