{% 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 'shop:my_orders' %}">Mes commandes</a>
        <a href="{% url 'profile' %}">Mon compte</a>
        <a href="{% url 'shop:product_list' %}">La boutique</a>
        <a href="{% url 'custom_logout' %}" class="red">Se déconnecter</a>
    {% else %}
        <a href="{% url 'login' %}">Se connecter</a>
        <a href="{% url 'shop:product_list' %}">La boutique</a>
    {% endif %}
</nav>

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

{% if form.errors or password_change_form.errors %}
<div class="cell medium-6 large-6 topblock padding10">
    <div class="bubble">
        <div>
            {% for field in form %}
                {% if field.errors %}
                    {% for error in field.errors %}
                    <div class="alert">{{ field.label }} : {{ error }}</div>
                    {% endfor %}
                {% endif %}
            {% endfor %}
        </div>
        <div>
            {% for field in password_change_form %}
                {% if field.errors %}
                    {% for error in field.errors %}
                    <div class="alert">{{ field.label }} : {{ error }}</div>
                    {% endfor %}
                {% endif %}
            {% endfor %}
        </div>
    </div>
</div>
{% endif %}

<div class="grid-x">
    <div class="cell medium-6 large-6 topblock padding10">
        <div class="bubble">
            <label class="title">Mes informations</label>
            <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 padding10">
        <div class="bubble">
            <label class="title">Mot de passe</label>
            <form method="post" action="{% url 'custom_password_change' %}">
                {% csrf_token %}
                {{ password_change_form.as_p }}
                <button type="submit" class="rounded-button">Modifier le mot de passe</button>
            </form>
        </div>
    </div>
</div>
{% endblock %}
