<?php

$title = 'Sign in';
require_once('head-auth.php') ?>

<body style="background-image: url(assets/images/background/3.jpeg);">

    <div class="uk-grid-collapse uk-flex" style="height: 100vh;" data-uk-grid>
        <div class="uk-padding-large uk-flex uk-flex-middle uk-flex-center row mx-auto" data-uk-height-viewport>
            <div class="row flex-column card text-13">
                <div class="uk-text-center text-theme pt-40">
                </div>
                <div class="pdd-horizon-30 pdd-vertical-30">
                    <div class="uk-text-center uk-margin">
                        <p class="uk-margin-remove">To proceed, input your account details.</p>
                    </div>
                    <form class="sign_in_form">
                        <div class="uk-width-1-1 uk-margin">
                            <!-- <label class="uk-form-label" for="email">Email</label> -->
                            <input name="sign_in_email" class="uk-input uk-form-large form-control text-13" type="email" placeholder="Email">
                        </div>
                        <div class="uk-width-1-1 uk-margin">
                            <!-- <label class="uk-form-label" for="password">Password</label> -->
                            <input name="sign_in_password" class="uk-input uk-form-large form-control text-13" type="password" placeholder="Password">
                        </div>
                        <div class="uk-width-1-1 uk-margin uk-text-right flex justify-between text-13">
                            <p class=" uk-margin-remove"><a class="" href="register">Sign Up</a></p>
                            <p class=" uk-margin-remove"><a class="" href="account-recovery">Forgot Password?</a></p>
                        </div>
                        <div class="uk-width-1-1 uk-text-center">
                            <a class="uk-button btn-secondary text-white uk-button-large sign_in_btn btn font-poppins">
                                Sign in
                            </a>
                        </div>

                        <!-- <div class="uk-width-1-1 uk-margin uk-text-center">
                            <h6 class="uk-text-small uk-margin-remove">Not registered? <a class="uk-link-border " href="register">Sign Up</a> </h6>
                        </div> -->
                    </form>
                </div>
            </div>
        </div>
        <!-- midnight-hacker anonymous -->
        <!-- <div class="uk-width-1-2@m right-cover uk-padding-large uk-flex uk-flex-middle uk-flex-center uk-light
    uk-background-cover uk-background-norepeat" style="background-image: url(assets/images/New/girl-hacker.jpeg);" data-uk-height-viewport>
        </div> -->
    </div>

    <!-- customs scripts starts -->
    <?php require_once('scripts-auth.php') ?>
    <!-- dashboard js ends -->

    <script>
        $(document).ready(function() {

            let referrer = $('.referrer').text();
            if (referrer.length !== 0) {
                $('.registerModal').modal('show');
            }


            $('.sign_in_btn').click(async function(e) {
                e.preventDefault();
                let sign_in_form = $('.sign_in_form').serializeArray();
                // console.log(sign_in_form);
                // return;
                let form_data = set_form_data(sign_in_form);
                let returned = await ajaxRequest('ajax.php', form_data);

                if (returned.error == 1) {
                    toastr.error(returned.msg)
                    // Swal.fire("Sorry", returned.msg, "error");
                } else if (returned.error == 0) {
                    toastr.success("Congratulations, " + returned.msg + ' ' + returned.first_name)
                    // Swal.fire("Congratulations!", returned.msg + ' ' + returned.first_name, "success");
                    setTimeout(() => {
                        window.location.href = '../user/overview';
                    }, 2000);
                }
            });

            $('.register_user_btn').click(async function(e) {
                e.preventDefault();
                let register_form = $('.register_form').serializeArray();
                // console.log(register_form);return;
                let form_data = set_form_data(register_form);
                let returned = await ajaxRequest('ajax.php', form_data);
                throwSweetalert(returned, './login', 1);
                // console.log(returned);return;
            });

        });
    </script>

</body>

</html>