{% extends "views/platform-admin/_base_template.html" %}
{% from "components/live-search.html" import live_search %}
{% from "components/components/button/macro.njk" import usaButton %}

{% block per_page_title %}
  Organizations
{% endblock %}

{% block platform_admin_content %}

  <h1 class="font-body-2xl">Organizations</h1>

  {{ live_search(target_selector='.browse-list-item', show=True, form=search_form, label='Search by name') }}

  <nav class="browse-list">
    <ul>
      {% for org in organizations|sort %}
        <li class="browse-list-item">
          <a href="{{ url_for('main.organization_dashboard', org_id=org.id) }}" class="usa-link">{{ org.name }}</a>
          {% if not org.active %}
            <span class="table-field-status-default heading-medium">- archived</span>
          {% endif %}
          <p class="browse-list-hint">
            {{ org.count_of_live_services }}
            live service{% if org.count_of_live_services != 1 %}s{% endif %}
          </p>
        </li>
      {% endfor %}
    </ul>
  </nav>

  <div class="js-stick-at-bottom-when-scrolling">
    {{ usaButton({
      "element": "a",
      "text": "New organization",
      "href": url_for('main.add_organization'),
      "classes": "govuk-button--secondary"
    }) }}
  </div>

{% endblock %}
