{% extends "fellchensammlung/base.html" %}
{% load i18n %}
{% load account %}

{% block title %}<title>{% user_display user %}</title>{% endblock %}


{% block content %}
    <div class="level is-mobile">
        <div class="level-left">
            <div class="level-item">
                <h1 class="title is-1"><i class="fas fa-user"></i> {{ user.get_full_name }}</h1>
            </div>
        </div>
        <div class="level-right">
            <div class="level-item">
                <form class="" action="{% url 'account_logout' %}" method="post">
                    {% csrf_token %}
                    <button class="button" type="submit">
                        <i aria-hidden="true" class="fas fa-sign-out fa-fw"></i> Logout
                    </button>
                </form>
            </div>
        </div>
    </div>

    <div class="block">
        <h2 class="title is-2">{% trans 'Profil verwalten' %}</h2>
        <div class="block"><strong>{% translate "E-Mail" %}:</strong> {{ user.email }}</div>
        {% if user.id is request.user.id %}
            <div class="block">
                <div class="field is-grouped is-grouped-multiline">
                    <div class="control">
                        <a class="button is-warning"
                           href="{% url 'account_change_password' %}">{% translate "Passwort ändern" %}</a>
                    </div>
                    <div class="control">
                        <a class="button is-warning"
                           href="{% url 'account_email' %}">
                            {% translate "E-Mail Adresse ändern" %}
                        </a>
                    </div>
                    <div class="control">
                        <a class="button is-warning"
                           href="{% url 'mfa_index' %}">
                            {% translate "2-Faktor Authentifizierung" %}
                        </a>
                    </div>
                    <div class="control">
                        <a class="button is-info" href="{% url 'user-me-export' %}">
                            {% translate "Daten exportieren" %}
                        </a>
                    </div>
                </div>
            </div>

            <div class="block">
                <h2 class="title is-2">{% trans 'Einstellungen' %}</h2>
                <form class="block" action="" method="POST">
                    {% csrf_token %}
                    {% if user.email_notifications %}
                        <label class="toggle">
                            <input type="submit" class="toggle-checkbox checked" name="toggle_email_notifications">
                            <div class="toggle-switch round "></div>
                            <span class="slider-label">
                        {% translate 'E-Mail Benachrichtigungen' %}
                        </span>
                        </label>
                    {% else %}
                        <label class="toggle">
                            <input type="submit" class="toggle-checkbox" name="toggle_email_notifications">
                            <div class="toggle-switch round"></div>
                            <span class="slider-label">
                        {% translate 'E-Mail Benachrichtigungen' %}
                        </span>
                        </label>
                    {% endif %}
                </form>
                <details>
                    <summary><strong>{% trans 'Erweiterte Einstellungen' %}</strong></summary>
                    <div class="block">
                        {% if token %}
                            <form action="" method="POST">
                                {% csrf_token %}
                                <p class="text-muted"><strong>{% translate "API token:" %}</strong> {{ token }}</p>
                                <input class="button is-danger" type="submit" name="delete_token"
                                       value={% translate "Delete API token" %}>
                            </form>
                        {% else %}
                            <p>{% translate "Kein API-Token vorhanden." %}</p>
                            <form action="" method="POST">
                                {% csrf_token %}
                                <input class="button is-primary" type="submit" name="create_token"
                                       value={% translate "Create API token" %}>
                            </form>
                        {% endif %}
                    </div>
                </details>

            </div>
        {% endif %}

        {% if show_mod_actions %}
            <div class="block">
                <h2 class="title is-2">{% trans 'Moderation' %}</h2>
                <div class="block">
                    <p><strong>{% translate 'Moderationsnotizen' %}:</strong> {{ user.mod_notes }}</p>
                </div>
                <div class="block">
                    {% if user.is_active %}
                        <a href="{% url 'user-deactivate' user_id=user.pk %}" class="button is-danger">
                            {% translate 'User deaktivieren' %}
                        </a>
                    {% else %}
                        <a href="{% url 'user-activate' user_id=user.pk %}" class="button is-info">
                            {% translate 'User aktivieren' %}
                        </a>
                    {% endif %}
                </div>
            </div>
        {% endif %}

        <h2 class="title is-2">{% translate 'Benachrichtigungen' %}</h2>
        {% include "fellchensammlung/lists/list-notifications.html" %}

        <h2 class="title is-2">{% translate 'Abonnierte Suchen' %}</h2>
        {% include "fellchensammlung/lists/list-search-subscriptions.html" %}

        <h2 class="title is-2">{% translate 'Vermittlungen' %}</h2>
        {% include "fellchensammlung/lists/list-adoption-notices.html" %}

{% endblock %}