{% extends "common/base.html" %}
{% load character_extras %}

{% block title %}Groupes{% endblock %}

{% block content %}
    <h1>Groupes</h1>
    <a href="{% url "party:create" %}" class="btn btn-primary mb-3">
        <i class="fa-solid fa-user-plus"></i> Nouveau groupe
    </a>
    {% if managed_parties %}
        <h2>Groupes que vous gérez</h2>
        <div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
            {% for party in managed_parties %}
                <div class="col">
                    <div class="card party" data-id="{{ party.pk }}">
                        <div class="card-body">
                            <h5 class="card-title">
                                {{ party.name }}
                            </h5>
                            <div class="btn-group btn-group-sm">
                                <a href="{% url "party:details" pk=party.pk %}" class="btn btn-success access">
                                    <i class="fa-solid fa-users"></i> Accéder
                                </a>
                                <a href="{% url "party:change" pk=party.pk %}" class="btn btn-secondary edit">
                                    <i class="fa-solid fa-gear"></i> Modifier
                                </a>
                                <a href="{% url "party:delete" pk=party.pk %}" class="btn btn-danger delete">
                                    <i class="fa-solid fa-users-slash"></i> Supprimer
                                </a>
                            </div>

                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% endif %}
    {% if played_parties %}
        <h2 class="mt-3">Groupes dont vous êtes membre</h2>
        <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4">
            {% for party in played_parties %}
                <div class="col">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">
                                {{ party.name }}
                            </h5>
                            <a href="{% url "party:details" pk=party.pk %}" class="btn btn-sm btn-success">
                                <i class="fa-solid fa-users"></i> Accéder
                            </a>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% endif %}
    {% if invited_to %}
        <h2 class="mt-3">Groupes auxquels vous avez été invités</h2>
        <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4">
            {% for party in invited_to %}
                <div class="col">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">
                                {{ party.name }}
                            </h5>
                            <a href="{% url "party:details" pk=party.pk %}" class="btn btn-sm btn-success">
                                <i class="fa-solid fa-users"></i> Accéder
                            </a>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% endif %}
{% endblock %}
