{% extends 'base.html.twig' %}

{% block title %}Liste des utilisateurs{% endblock %}

{% block body %}
    <div class="container mx-auto p-6">
        <h1 class="text-3xl font-bold mb-4">Liste des Utilisateurs</h1>

        <div class="overflow-x-auto bg-white shadow-lg rounded-lg">
            <table class="min-w-full table-auto">
                <thead>
                <tr class="bg-gray-800 text-white">
                    <th class="px-4 py-2 text-left">ID</th>
                    <th class="px-4 py-2 text-left">Nickname</th>
                    <th class="px-4 py-2 text-left">FirstName</th>
                    <th class="px-4 py-2 text-left">LastName</th>
                    <th class="px-4 py-2 text-left">Mail</th>
                    <th class="px-4 py-2 text-left">Actions</th>
                </tr>
                </thead>
                <tbody>
                {% for user_app in user_apps %}
                    <tr class="border-b">
                        <td class="px-4 py-2">{{ user_app.id }}</td>
                        <td class="px-4 py-2">{{ user_app.nickname }}</td>
                        <td class="px-4 py-2">{{ user_app.firstName }}</td>
                        <td class="px-4 py-2">{{ user_app.lastName }}</td>
                        <td class="px-4 py-2">{{ user_app.mail }}</td>
                        <td class="px-4 py-2">
                            <a href="{{ path('app_user_show', {'id': user_app.id}) }}" class="text-teal-500 hover:text-teal-700 mr-3">
                                <i class="fas fa-eye"></i> Voir
                            </a>

                            <a href="{{ path('app_user_edit', {'id': user_app.id}) }}" class="text-yellow-500 hover:text-yellow-700 mr-3">
                                <i class="fas fa-edit"></i> Modifier
                            </a>

                            <form method="post" action="{{ path('app_user_delete', {'id': user_app.id}) }}" style="display:inline;">
                                <input type="hidden" name="_method" value="DELETE">
                                <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ user_app.id) }}">
                                <button type="submit" class="text-red-500 hover:text-red-700">
                                    <i class="fas fa-trash-alt"></i> Supprimer
                                </button>
                            </form>
                        </td>
                    </tr>
                {% else %}
                    <tr>
                        <td colspan="6" class="text-center py-4">Aucun utilisateur trouvé</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}