<!DOCTYPE html>
<html lang="en">

<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">
    <link rel='stylesheet' href='../../dist/styles.css'>
    <title>Reset Password</title>
</head>

<body>
    <form class='resetPassword' id='resetPassword'>
        <label for='mail'>Your mail address</label>
        <input type='text' name='mail'>
        <button type='submit'>Submit</button>
    </form>

    <script>
        async function sendMail() {

        }

        const formSend = document.querySelector('form.resetPassword');
        formSend.addEventListener('submit', function (event) {
            event.preventDefault();
            const obj = new FormData(document.getElementById('resetPassword'))
            fetch('HTTP://localhost:2000/forgotPassword', {
                method: 'PUT',
                body: obj
            })
                .then(function (data) {
                    return data.json();
                })
                .then(function (data) {
                    if (data.success === false) {
                        alert('Admin did not found');
                    }
                    else {
                        alert('You got a mail')
                    }
                })
                .catch(function (err) {
                    console.log(err);
                })
        })
    </script>

</body>

</html>