{% import "macros/buttons.html" as buttons %}
{% import "macros/icons.html" as icons %}

{% extends "admin/tenants/list.html" %}

{% block head_title_content %}{{ tenant.name }} · {{ super() }}{% endblock %}

{% set open_aside = true %}

{% block aside %}
{% set base_url = tenant.get_host(current_workspace.domain) %}
<h2 class="text-slate-800 font-semibold text-center mb-6">{{ tenant.name }}</h2>
<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">Base URL</div>
      <div class="text-sm font-medium text-slate-800 ml-2 truncate">{{ base_url }}</div>
      {{ buttons.clipboard(base_url) }}
    </li>
    <li class="flex items-center justify-between py-3 border-b border-slate-200">
      <div class="text-sm whitespace-nowrap">Registration allowed</div>
      <div class="text-sm font-medium text-slate-800 ml-2 truncate">
        {% if tenant.registration_allowed %}
          {{ icons.check('w-4 h-4') }}
        {% else %}
          {{ icons.x_mark('w-4 h-4') }}
        {% endif %}
      </div>
    </li>
    <li class="flex items-center justify-between py-3 border-b border-slate-200">
      <div class="text-sm whitespace-nowrap">Logo</div>
      <div class="text-sm font-medium text-slate-800 ml-2 truncate">
        {% if tenant.logo_url %}
          <img src="{{ tenant.logo_url }}" alt="{{ tenant.name }}" class="object-contain h-4" />
        {% else %}
          —
        {% endif %}
      </div>
    </li>
    <li class="flex items-center justify-between py-3 border-b border-slate-200">
      <div class="text-sm whitespace-nowrap">UI Theme</div>
      <div class="text-sm font-medium text-slate-800 ml-2 truncate">
        {% if tenant.theme %}
          {{ tenant.theme.name }}
        {% else %}
          <span class="italic">Default</span>
        {% endif %}
      </div>
    </li>
  </ul>
</div>
<div class="mt-6">
  <div class="text-sm font-semibold text-slate-800 mb-1">OAuth Providers</div>
  <ul>
    {% for oauth_provider in tenant.oauth_providers %}
      <li class="flex items-center justify-between py-3 border-b border-slate-200">
        <div class="text-sm text-slate-800 ml-2 truncate">{{ oauth_provider.display_name }}</div>
      </li>
    {% endfor %}
  </ul>
</div>
<div class="mt-6 space-y-4">
  <a
    href="{{ url_for('dashboard.tenants:update', id=tenant.id) }}"
    class="btn w-full border-slate-200 hover:border-slate-300"
    hx-boost="true"
    hx-target="#modal"
    _="install OpenModal"
  >
    Edit Tenant
  </a>
  <a
    href="{{ url_for('dashboard.tenants:delete', id=tenant.id) }}"
    class="btn w-full bg-red-500 hover:bg-red-600 text-white"
    hx-boost="true"
    hx-target="#modal"
    _="install OpenModal"
  >
    Delete Tenant
  </a>
</div>
{% endblock %}
