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

{% block title %}List of Degrees{% endblock %}

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

        <!-- Tableau des diplômes -->
        <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">Label</th>
                    <th class="px-4 py-2 text-left">Actions</th>
                </tr>
                </thead>
                <tbody>
                {% for degree in degrees %}
                    <tr class="border-b">
                        <td class="px-4 py-2">{{ degree.id }}</td>
                        <td class="px-4 py-2">{{ degree.label }}</td>
                        <td class="px-4 py-2">
                            <!-- Voir le diplôme -->
                            <a href="{{ path('app_degree_show', {'id': degree.id}) }}" class="text-teal-500 hover:text-teal-700 mr-3">
                                <i class="fas fa-eye"></i> Voir
                            </a>

                            <!-- Modifier le diplôme -->
                            <a href="{{ path('app_degree_edit', {'id': degree.id}) }}" class="text-yellow-500 hover:text-yellow-700 mr-3">
                                <i class="fas fa-edit"></i> Modifier
                            </a>

                            <!-- Formulaire pour supprimer le diplôme -->
                            <form method="post" action="{{ path('app_degree_delete', {'id': degree.id}) }}" style="display:inline;">
                                <input type="hidden" name="_method" value="DELETE">
                                <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ degree.id) }}">
                                <button type="submit" class="text-red-500 hover:text-red-700">
                                    <i class="fas fa-trash-alt"></i> Supprimer
                                </button>
                            </form>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

        <!-- Lien pour ajouter un nouveau diplôme -->
        <div class="mt-4">
            <a href="{{ path('app_degree_new') }}" class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full">
                <i class="fas fa-plus-circle"></i> Ajouter un nouveau diplôme
            </a>
        </div>
    </div>
{% endblock %}