{% extends 'tournaments/base.html' %}
{% block head_title %} Mon Compte {% endblock %}
{% block first_title %} Mon Compte {% endblock %}
{% block second_title %} {{ user.first_name }} {{ user.last_name }} {% endblock %}

{% block content %}

<nav class="margin10">
    <a href="{% url 'index' %}" class="orange">Accueil</a>
    <a href="{% url 'clubs' %}" class="orange">Clubs</a>
    {% if user.is_authenticated %}
        <a href="{% url 'my-tournaments' %}" class="orange">Mes tournois</a>
        <a href="{% url 'profile' %}">Mon compte</a>
        <a href="{% url 'custom_logout' %}" class="red">Se déconnecter</a>
    {% else %}
        <a href="{% url 'login' %}">Se connecter</a>
    {% endif %}
</nav>

{% load static %}
{% load tz %}

<div class="cell medium-6 large-6 topblock my-block">
    <div class="bubble">
        <label class="title">Mes informations</label>
        {% if form.errors %}
            <div class="alert">
                {% for field, errors in form.errors.items %}
                    {% for error in errors %}
                        <p>{{ error }}</p>
                    {% endfor %}
                {% endfor %}
            </div>
        {% endif %}

        <!-- Add non-field errors (if any) -->
        {% if form.non_field_errors %}
            <div class="alert">
                {% for error in form.non_field_errors %}
                    <p>{{ error }}</p>
                {% endfor %}
            </div>
        {% endif %}
        <form method="post">
            {% csrf_token %}
            {{ form.as_p }}
            <button type="submit" class="rounded-button">Sauver les changements</button>
        </form>
    </div>
</div>
<div class="cell medium-6 large-6 topblock my-block">
    <div class="bubble">
        <label class="title">Mot de passe</label>
        {% if password_change_form.errors %}
            <div class="alert">
                {% for field, errors in password_change_form.errors.items %}
                    {% for error in errors %}
                        <p>{{ error }}</p>
                    {% endfor %}
                {% endfor %}
            </div>
        {% endif %}

        {% if password_change_form.non_field_errors %}
            <div class="alert">
                {% for error in password_change_form.non_field_errors %}
                    <p>{{ error }}</p>
                {% endfor %}
            </div>
        {% endif %}

        <form method="post" action="{% url 'password_change' %}">
            {% csrf_token %}
            {{ password_change_form.as_p }}
            <button type="submit" class="rounded-button">Modifier le mot de passe</button>
        </form>
    </div>
</div>
{% endblock %}
