{% extends 'tournaments/base.html' %}
{% load tournament_tags %}

{% block head_title %}{{ head_title }}{% endblock %}
{% block first_title %}{{ first_title }}{% endblock %}
{% block second_title %}{{ second_title }}{% endblock %}

{% block content %}

{% include 'tournaments/navigation_base.html' %}

    {% if filter == 0 or filter == 2 %}
    <!-- Year Navigation -->
    {% if available_years %}

    <div class="topmargin40">
    <nav class="margin10">
        {% for year in available_years %}
            {% if year == selected_year %}
                <a href="?filter={{ filter }}{% if club %}&club={{ club }}{% endif %}&year={{ year }}&month={{ selected_month }}" class="download-button">{{ year }}</a>
            {% else %}
                <a href="?filter={{ filter }}{% if club %}&club={{ club }}{% endif %}&year={{ year }}&month={{ selected_month }}" class="orange">{{ year }}</a>
            {% endif %}
        {% endfor %}
    </nav>
    {% endif %}

    <!-- Month Navigation -->
    {% if available_months and selected_year %}
    <nav class="margin10">
        {% for month_num in available_months %}
            {% if month_num == selected_month %}
                <a href="?filter={{ filter }}{% if club %}&club={{ club }}{% endif %}&year={{ selected_year }}&month={{ month_num }}" class="download-button">{{ month_names|array_lookup:month_num }}</a>
            {% else %}
                <a href="?filter={{ filter }}{% if club %}&club={{ club }}{% endif %}&year={{ selected_year }}&month={{ month_num }}" class="orange">{{ month_names|array_lookup:month_num }}</a>
            {% endif %}
        {% endfor %}
    </nav>
    </div>

    {% endif %}
    {% endif %}

    <div class="grid-x">
        {% if tournaments %}
        <div class="cell medium-12 large-6 topblock padding10">
            <div>

                {% for tournament in tournaments %}
                {% include 'tournaments/tournament_row.html' %}
                {% endfor %}

            </div>
        </div>
        {% elif selected_month and selected_year %}
        <div class="cell medium-12 large-6 topblock padding10">
            <div class="bubble">
                <p>Aucun tournoi trouvé pour {{ month_names|array_lookup:selected_month }} {{ selected_year }}.</p>
            </div>
        </div>
        {% elif selected_year %}
        <div class="cell medium-12 large-6 topblock padding10">
            <div class="bubble">
                <p>Aucun tournoi trouvé pour l'année {{ selected_year }}.</p>
            </div>
        </div>
        {% endif %}

        {% if first_tournament_prog_url and tournaments %}
        <div class="cell medium-6 large-6 topblock padding10">
        <div class="bubble">
            <a href="{{ first_tournament_prog_url }}" class="large-button semibold orange topmargin5">Voir la programmation de l'événement</a>
            <hr/>
            <p>
                <div class="semibold">Infos</div>
                <div class="tournament-info">
                    {{ tournaments.count }} tournois
                </div>
            </p>
        </div>
        </div>
        {% endif %}

    </div>

{% endblock %}
