{#
  Copyright (C) 2024 I-Form.

  invenio-theme-iform is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}
{% extends "invenio_administration/base.html" %}

{% block admin_page_content %}
<div class="ui container dashboard rel-mt-5">
  <div class="ui grid">
    <div class="sixteen wide column">
      <h2 class="ui header">
        <i class="setting icon"></i>
        <div class="content">
          {{ _("Registration Settings") }}
          <div class="sub header">{{ _("Enable or disable public user registration on the website.") }}</div>
        </div>
      </h2>

      {% with messages = get_flashed_messages(with_categories=true) %}
        {% if messages %}
          {% for category, message in messages %}
            <div class="ui {{ 'positive' if category == 'success' else 'negative' }} message">
              {{ message }}
            </div>
          {% endfor %}
        {% endif %}
      {% endwith %}

      <div class="ui segment">
        <h3 class="ui header">{{ _("Public Sign-up Status") }}</h3>
        
        <p>
          {% if registration_enabled %}
            <span class="ui green large label"><i class="check icon"></i> {{ _("Public Sign-ups ENABLED") }}</span>
          {% else %}
            <span class="ui red large label"><i class="ban icon"></i> {{ _("Public Sign-ups DISABLED") }}</span>
          {% endif %}
        </p>

        <div class="ui divider"></div>

        <form method="POST" class="ui form">
          {% if registration_enabled %}
            <input type="hidden" name="registration_enabled" value="false">
            <button type="submit" class="ui red button">
              <i class="ban icon"></i> {{ _("Disable Public Sign-ups") }}
            </button>
          {% else %}
            <input type="hidden" name="registration_enabled" value="true">
            <button type="submit" class="ui green button">
              <i class="check icon"></i> {{ _("Enable Public Sign-ups") }}
            </button>
          {% endif %}
        </form>
      </div>
    </div>
  </div>
</div>
{% endblock %}
