<!DOCTYPE html>
<html lang="fr">
    <head>
        <title>Math'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">
        <link rel="stylesheet" href="../css/global.css">
    </head>

    <body id="bodyStyle">
        <div>
            <a href="/" role="button" class="btn btn-secondary position-absolute top-0 mt-2 end-0 me-2">
                Retour
            </a>
        </div>
        <div class="container mt-5 text-light fs-4">
            <h1>Liste des administrators</h1> 
            <p class="text-center bg-danger"> {{ error }} </p>
            <ul class="list-group">
                {% for admin in administrators %}
                    <li class="list-group-item d-flex justify-content-between align-items-center border-dark text-light bg-secondary">
                        {{ admin.username }}
                        <div class="btn-group" role="group">
                            <a type="button" href="/admin/administrators/updatemodal/{{ admin.id }}"  class="btn btn-primary fs-5">Modifier</a>
                            <a type="button" href="/admin/administrators/delete/{{ admin.id }}" class="btn btn-danger fs-5">Supprimer</a>
                        </div>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="container mt-3 d-flex justify-content-between">
            <a type="button" href="/admin/questions" class="btn btn-secondary fs-5"> ← Questions </a>
            <button type="button" class="btn btn-primary fs-5" data-bs-toggle="modal" data-bs-target="#modalAdministrators">Ajouter un administrateur</button>
            <a type="button" href="/admin/chapters" class="btn btn-secondary fs-5">Chapitres →</a>
        </div>

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

        <div class="modal fade" id="modalAdministrators">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Ajouter un administrateur</h5>
                    </div>
                    <form method="POST" action="/admin/administrators/add">
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="username">Nom d'utilisateur :</label>
                                <input type="text" class="form-control" id="username" name="username">
                            </div>
                            <div class="form-group">
                                <label for="password">Mot de passe :</label>
                                <input type="password" class="form-control" id="password" name="password">
                            </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>
