{% extends 'base.jinja2' %}
{% import 'macros/form_macros.jinja2' as mform %}
{% block content %}
    <div class="col-12 ">
        <div class="row justify-content-center justify-content-sm-center">

            {% if not form %}
                <div class="col-12 col-sm-8 col-md-7 col-lg-5 col-xl-4 bg-white text-dark p-3 mt-5">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">{{ user.username }}</h5>
                            <h6 class="card-subtitle mb-2 text-muted">{{ user.first_name }}, {{ user.last_name }}</h6>
                            <ul class="list-group list-group-flush">
                                {% if groups %}
                                    <li class="list-group-item">
                                        <span class="font-weight-bold">Gruppen:</span>
                                        {% for group in groups %}
                                            {{ group.name }}
                                        {% endfor %}
                                    </li>
                                {% endif %}
                                <li class="list-group-item"><span
                                        class="font-weight-bold">Email:</span> {{ user.email }}</li>
                                <li class="list-group-item"><span
                                        class="font-weight-bold">Passwort:</span> {{ user.password }} <a
                                        href="{{ url('password_change') }}">Passwort ändern</a>
                                </li>
                                <li class="list-group-item"><span
                                        class="font-weight-bold">Telefon:</span> {{ user.phone }}</li>
                                <li class="list-group-item"><span
                                        class="font-weight-bold">Mobiltelefon:</span> {{ user.mobile_phone }}</li>
                            </ul>
                            <div class="card-footer d-flex">
                                <a href="{{ url('user-update', args = [user.dn, realm.id]) }}"
                                   class="btn btn-primary mr-auto p-2">Update
                                    User</a>
                                <a href="{{ url('user-delete-confirm', args = [user.dn, realm.id]) }}"
                                   class="btn btn-danger p-2">Delete
                                    User</a>
                            </div>
                        </div>
                    </div>
                </div>
            {% else %}
                <div class="col-12 col-sm-8 col-md-7 col-lg-5 col-xl-4 bg-white text-dark p-3 mt-5 border">
                    <h1 class="mb-4">Nutzerdetails anpassen</h1>
                    <form method="post" class="floating-label-form">
                        <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
                        {{ mform.email_input(form.email) }}
                        {{ mform.password_input(form.password) }}
                        {{ mform.text_input(form.first_name) }}
                        {{ mform.text_input(form.last_name) }}
                        <div class="d-flex mt-4">
                            <button type="submit" class="btn btn-primary mr-auto p-2">Speichern</button>
                            <a href="{{ url('realm-user-detail', args = [realm.id, user.dn]) }}"
                               class="btn btn-secondary p-2">Abbrechen</a>
                        </div>
                    </form>
                </div>
            {% endif %}
        </div>
    </div>
    </div>
{% endblock %}