{% extends "admin/clients/get/base.html" %}

{% block tab %}
<div class="mt-6">
  <ul>
    <li class="flex items-center justify-between py-3 border-b border-slate-200">
      <div class="text-sm whitespace-nowrap">Type</div>
      <div class="text-sm font-medium text-slate-800 ml-2 truncate">{{ client.client_type.get_display_name() }}</div>
    </li>
    <li class="flex items-center justify-between py-3 border-b border-slate-200">
      <div class="text-sm whitespace-nowrap">ID</div>
      <div class="text-sm font-medium text-slate-800 ml-2 truncate">{{ client.client_id }}</div>
      {{ buttons.clipboard(client.client_id) }}
    </li>
    <li class="flex items-center justify-between py-3 border-b border-slate-200">
      <div class="text-sm whitespace-nowrap">Secret</div>
      <div class="text-sm font-medium text-slate-800 ml-2 truncate">{{ client.client_secret }}</div>
      {{ buttons.clipboard(client.client_secret) }}
    </li>
  </ul>
</div>
<div class="mt-6">
  <div class="text-sm font-semibold text-slate-800">Redirect URIs</div>
  <ul class="mb-3">
    {% for redirect_uri in client.redirect_uris %}
      <li class="flex items-center justify-between py-3 border-b border-slate-200">
        <div class="text-sm whitespace-nowrap truncate">{{ redirect_uri }}</div>
      </li>
    {% endfor %}
  </ul>
  <a
    href="{{ url_for('dashboard.clients:update', id=client.id) }}"
    class="btn w-full border-slate-200 hover:border-slate-300"
    hx-boost="true"
    hx-target="#modal"
    _="install OpenModal"
  >
    Edit Client
  </a>
</div>
<div class="mt-6">
  <div class="text-sm font-semibold text-slate-800">ID Token Encryption</div>
  <div class="pb-4 border-b border-slate-200">
    <div class="flex justify-between text-sm mb-2">
      <div>
        {% if client.encrypt_jwk %}
          Enabled
        {% else %}
          Disabled
        {% endif %}
      </div>
    </div>
    <button
      type="button"
      {% if client.encrypt_jwk %}
      class="btn w-full bg-yellow-500 hover:bg-yellow-600 text-white"
      {% else %}
      class="btn w-full border-slate-200 hover:border-slate-300"
      {% endif %}
      hx-post="{{ url_for('dashboard.clients:encryption_key', id=client.id) }}"
      hx-trigger="click"
      hx-target="#modal"
      _="
        install OpenModal
        on htmx:afterOnLoad
          call htmx.ajax(
            'GET',
            '{{ url_for('dashboard.clients:get', id=client.id) }}',
            '#aside'
          )
        end
      "
    >
      {% if client.encrypt_jwk %}
        Regenerate key
      {% else %}
        Generate key
      {% endif %}
    </button>
  </div>
  <div class="mt-6">
    <a
      href="{{ url_for('dashboard.clients:delete', id=client.id) }}"
      class="btn w-full bg-red-500 hover:bg-red-600 text-white"
      hx-boost="true"
      hx-target="#modal"
      _="install OpenModal"
    >
      Delete Client
    </a>
  </div>
</div>
{% endblock %}
