<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Se connecter</title>
    <link rel="stylesheet" href="css\login.css">
</head>
<body>
    <div class="center">
        <h1>Identifiez-vous</h1>
        <h5 id="erreur-statuts"></h5>
        <form method="post" id="se_connecter_form" enctype="multipart/form-data">
        <?php echo csrf_field(); ?>
            <div class="txt_field">
                <input type="text" name="nomutil" id="nomutil" required>
                <span></span>
                <h5 id="erreur"></h5>
                <label for="">Nom d'utilisateur</label>
            </div>
            <div class="txt_field">
                <input type="password" name="mdp" id="mdp" required>
                <span></span>
                <h5 id="erreur-mdp"></h5>
                <label for="">Mot de passe</label>
                
            </div>
            <div class="pass"><a href="/oublie">Mot de passe oublié?</a></div>
            <input type="submit" value="Connexion" id="login_btn">
        </form>
    </div>

    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/js/bootstrap.bundle.min.js'></script>
    <script>

        $("#se_connecter_form").submit(function(e) {
            e.preventDefault();
            const fd = new FormData(this);
            $("#login_btn").text('Connexion en cour...');
            $.ajax({
                url: '<?php echo e(route('connexion')); ?>',
                method: 'post',
                data: fd,
                cache: false,
                contentType: false,
                processData: false,
                success: function(res) {
                    console.log(res);
                    if (res.status == 200) {
                        window.location.href="/demandesencours";
                    }else{
                        let error = document.getElementById('erreur');
                        
                        error.style.visibility = 'visible';
                        $("#erreur").text(res.info);
                    }
                    $("#se_connecter_form")[0].reset();
                }
            });
        });

    </script>
</body>
</html><?php /**PATH F:\facture\resources\views/login.blade.php ENDPATH**/ ?>