@using GheyasPlusShop.Utils;
@using Utils;
@{
    ViewBag.Title = "ورود به حساب کاربری ادمین";
}

@section styles{
    <style>
        body {
            background-color: #eceff1;
            direction: rtl;
        }

        .section-error {
            height: 38px;
            color: red;
            margin-bottom: 8px;
            overflow: hidden;
        }


        .button-accept {
            width: 100%;
            height: 46px;
            background-color: #00838f;
        }

            .button-accept img {
                margin-left: 10px;
                height: 24px;
            }
    </style>
}

<div class="container-fluid">
    <div class="row">
        <div class="col-5 center-vertical" style="padding:0 100px;height: calc(100vh);">
            <div style="padding: 60px 40px;border-radius: 8px;background-color: #fff;">
                <div class="text-center" style="font-size: 16px; font-weight: 700; margin-bottom: 40px;">ورود به پنل مدیریت فروشگاه</div>
                <div class="has-float-label">
                    <input type="text" class="text-control" id="userLogin" data-required="true" />
                    <span>نام کاربری</span>
                </div>
                <div class="has-float-label" style="margin: 30px 0 10px; ">
                    <input type="password" class="text-control" id="passwordLogin" data-required="true" />
                    <span>کلمه عبور</span>
                </div>
                <div class="section-error">
                    <span id="spLoginrError"></span>
                </div>
                <div>
                    <button type="button" class="button-accept" onclick="Login()">
                        <img src="~/App_Images/index/Login.svg" />ورود
                    </button>
                </div>
            </div>
        </div>
        <div class="col-7 center-vertical" style="height:100vh;background-image:url('../../App_Images/BGAdminLogin.svg');background-size: cover;background-position: center;background-repeat: no-repeat;">
        </div>
    </div>
</div>


@section scripts{
    <script>

        function Login() {
            var error = checkValidation();
            if (error)
                return;
            ajax({
                loading: true,
                url: "Admin/LoginAdmin",
                data: JSON.stringify({ userName: $("#userLogin").val(), passWord: $("#passwordLogin").val() }),
                success: function (result) {
                    window.location.reload();
                },
                error: function (err) {
                    var errorMsg;
                    if (err.responseJSON)
                        errorMsg = err.responseJSON.Message;
                    else
                        errorMsg = err.responseText;
                    $('#spLoginrError').text(errorMsg);
                    closeLoading();
                },
                complete: function () {
                }
            });
        }

        $("#userLogin").on("keypress", function (event) {
            if (event.keyCode === 13)
                $("#passwordLogin").focus();
        });

        $("#passwordLogin").on("keypress", function (event) {
            if (event.keyCode === 13)
                Login();
        });

    </script>
}
