<div class="page" >
    <div class="login-wrap">
        <div class="pageTitle text-center">
            <h2>Reset</h2>
        </div>
        <form method="POST" id="form_login">
            <div class="mb-3">
                <label for="" class="form-label">Email</label>
                <input type="text" class="form-control" id="inp-email" name="email" autocomplete="off">
                <div class="feedback-email mt-1 text-danger"></div>
            </div>
            <div class="mt-5 mb-2">
                <button class="w-100 btn btn-lg btn-primary">
                    <span class="spinner-border spinner-border-sm text-white d-none" role="status"> 
                        <span class="sr-only">Loading...</span> 
                    </span>
                    Reset kata sandi
                </button>
            </div>
        </form>
    </div>
</div>

<script>
    $('form').on('submit', function(e) {
        e.preventDefault();
        let form = $(this);
        $.post({
            url: base_url + 'auth/proses_login',
            data: form.serialize(),
            dataType: 'json',
            success: function(json) {
                if(json.status == 1) {
                    window.location.href = base_url + 'akun'
                    $('#inp-email, #inp-pass').removeClass('is-invalid');

                } else {
                    if(json.status == 0) {
                        toast({
                            title: json.msg,
                            icon: 'error'
                        });

                        if(json.type == 'email') {
                            $('#inp-email').addClass('is-invalid');
                            $('#inp-pass').removeClass('is-invalid');

                        } else if(json.type == 'pass') {
                            $('#inp-pass, #inp-email').addClass('is-invalid');

                        } else {
                            $('#inp-pass, #inp-email').removeClass('is-invalid');
                        }
                    }
                }
            }
        });
    })
</script>