{% extends "layout.html.j2" %}

{% block scripts %}
{% endblock%}

{% block content %}
<div>
    <h1>Upcoming tournaments</h1>
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th scope="col">Name</th>
                <th scope="col">Date</th>
                <th scope="col">Location</th>
                <th scope="col">Rank</th>
                <th scope="col">Status</th>
            </tr>
        </thead>
        <tbody>
            {% for tournament in tournaments %}
            <tr>
                <th scope="row"><a href="{{ url_for('tournament_display', uid=tournament.uid) }}">{{
                        tournament.name }}</a></th>
                {% if tournament.finish %}
                <td>
                    {{ tournament.start.strftime("%Y-%m-%d %H:%M") }}
                    <i class="bi bi-arrow-right"></i>
                    {{ tournament.finish.strftime("%Y-%m-%d %H:%M") }}
                    ({{ tournament.timezone }})
                </td>
                {% else %}
                <td>{{ tournament.start.strftime("%Y-%m-%d %H:%M") }} ({{ tournament.timezone }})</td>
                {% endif %}
                {% if tournament.online %}
                <td>Online</td>
                {% else %}
                <td>{{ tournament.country }}</td>
                {% endif %}
                <td>{{ tournament.rank }}</td>
                <td>{{ tournament.state }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% if member %}
    <a href="{{ url_for('tournament_create') }}" class="btn btn-primary">Create Tournament</a>
    {% endif %}
</div>
{% endblock %}