@using CarCareTracker.Helper
@inject IConfigHelper config
@inject ITranslationHelper translator
@model string
@{
    var userLanguage = config.GetServerLanguage();
    var registrationDisabled = config.GetServerDisabledRegistration();
    var openIdConfigName = config.GetOpenIDConfig().Name;
}
@{
    ViewData["Title"] = "Login";
}
@section Scripts {
    <script src="~/js/login.js?v=@StaticHelper.VersionNumber"></script>
}
<div class="container d-flex align-items-center justify-content-center" style="height:100vh">
    <div>
        <div style="max-width:204px;">
            <img src="@config.GetLogoUrl()" class="lubelogger-logo" />
            <div class="form-group">
                <label for="inputUserName">@translator.Translate(userLanguage, "Username")</label>
                <input type="text" id="inputUserName" class="form-control">
            </div>
            <div class="form-group">
                <label for="inputUserPassword">@translator.Translate(userLanguage, "Password")</label> 
                <div class="input-group">
                    <input type="password" id="inputUserPassword" onkeyup="callBackOnEnter(event, performLogin)" class="form-control">
                    <div class="input-group-text">
                        <button type="button" class="btn btn-sm text-secondary password-visible-button" onclick="togglePasswordVisibility(this)"><i class="bi bi-eye"></i></button>
                    </div>
                </div>
            </div>
            <div class="form-check form-switch">
                <input class="form-check-input" type="checkbox" role="switch" id="inputPersistent">
                <label class="form-check-label" for="inputPersistent">@translator.Translate(userLanguage, "Remember Me")</label>
            </div>
            <div class="d-grid">
                <button type="button" class="btn btn-warning mt-2" onclick="performLogin()"><i class="bi bi-box-arrow-in-right me-2"></i>@translator.Translate(userLanguage, "Login")</button>
            </div>
            @if (!string.IsNullOrWhiteSpace(openIdConfigName))
            {
                <div class="d-grid">
                    <button type="button" class="btn btn-secondary mt-2" onclick="remoteLogin()"><i class="bi bi-box-arrow-in-right me-2"></i>@($"{translator.Translate(userLanguage, "Login via")} {openIdConfigName}")</button>
                </div>
            }
            <div class="d-flex justify-content-center">
                <div class="form-group">
                    <small class="text-body-secondary">@config.GetMOTD()</small>
                </div>
            </div>
            <div class="d-grid">
                <a href="/Login/ForgotPassword" class="btn btn-link mt-2">@translator.Translate(userLanguage, "Forgot Password")</a>
            </div>
            @if (!registrationDisabled)
            {
                <div class="d-grid">
                    <a href="/Login/Registration" class="btn btn-link mt-2">@translator.Translate(userLanguage, "Register")</a>
                </div>
            }
        </div>
    </div>
</div>
<script>
    function getRedirectURL() {
        return { url: decodeHTMLEntities('@Model') };
    }
</script>