<!DOCTYPE html>
<html lang="fr">
    <head>
        <title>Maths Educ</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
        </script>
        <link rel="stylesheet" href="css/global.css">
    </head>

    <body>
        <div class="container mt-5">
            <h1>Liste des chapitres</h1>
            <ul class="list-group">
                {% for chapter in chapters %}
                    <li class="list-group-item d-flex ustify-content-between align-items-center">
                        {{ chapter.name }}
                        <div class="btn-group" role="group">
                            <a type="button" href="/admin/chapters/updatemodal/{{ chapter.id }}"  class="btn btn-primary">Modifier</a>
                            <a type="button" href="/admin/chapters/delete/{{ chapter.id }}" class="btn btn-danger">Supprimer</a>
                        </div>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="container mt-3">
            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalchapters">Ajouter un chapitre</button>
            <div class="btn-group" role="group">
                <a href="/admin/administrators" class="btn btn-secondary"> ← Administrateur</a>
                <a href="/" class="btn btn-secondary">Retour</a>
                <a href="/admin/questions" class="btn btn-secondary">Questions →</a>
            </div>
        </div>

        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

        <div class="modal fade" id="modalchapters">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Ajouter un chapitre</h5>
                    </div>
                    <form method="POST" action="/admin/chapters/add">
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="name">Nom du chapitre :</label>
                                <input type="text" class="form-control" id="name" name="name">
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
                            <button type="submit" class="btn btn-primary">Enregistrer</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </body>
</html>
