<!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 class="modal fade" id="modalUpdatePlayers">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Modifier votre mot de passe</h5>
                    </div>
                    <form method="POST" action="/user/players/update">
                        <div class="modal-body">
                            <div class="form-group">
                                <input type="hidden" class="form-control" id="updateId" name="id">
                            </div>
                            <div class="form-group">
                                <label for="password">Mot de passe :</label>
                                <input type="password" class="form-control" id="updatePassword" 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>

        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
        
        <script>
                if ({{ player.id }} != 0) {
                    window.onload = showModal();

                    function showModal() {
                        var modal = new bootstrap.Modal(document.getElementById('modalUpdatePlayers'));

                        var id = document.getElementById('updateId');
                        var password = document.getElementById('updatePassword');

                        id.value = "{{ player.id }}";
                        password.value = "{{ player.hashedPassword }}";

                        modal.show();
                    }
                }
        </script>
    </body>
</html>
