@inherits Dynamicweb.Rendering.ViewModelTemplate<UserChangePasswordViewModel>
@using Dynamicweb.Users.Frontend.UserChangePassword

<div class="mx-auto w-100" style="max-width: 30rem;">
    @if (Model.Result == UserChangePasswordResultType.MismatchedPasswords)
    {
        <div class="alert alert-danger" role="alert">
            @Translate("The passwords do not match. Please try again")
        </div>
    } 
    else if (Model.Result == UserChangePasswordResultType.InvalidPasswordLength)
    {
        <div class="alert alert-danger" role="alert">
            @Translate("The password must be longer")
        </div>
    } 
    else if (Model.Result == UserChangePasswordResultType.InvalidPasswordComplexity)
    {
        <div class="alert alert-danger" role="alert">
            @Translate("The password is too simple. Try using a mix of uppercase, lowercase, numbers and special characters")
        </div>
    } 
    else if (Model.Result == UserChangePasswordResultType.InvalidOldPassword)
    {
        <div class="alert alert-danger" role="alert">
            @Translate("The old password is incorrect")
        </div>
    } 
    else if (Model.Result == UserChangePasswordResultType.ViolatingReuseRules)
    {
        <div class="alert alert-danger" role="alert">
            @Translate("The new password must be different from the old password")
        </div>
    } 
    else if (Model.Result == UserChangePasswordResultType.MustContainNumbersAndCharacters)
    {
        <div class="alert alert-danger" role="alert">
            @Translate("The password must contain both numbers and letters")
        </div>
    } 
    else if (Model.Result == UserChangePasswordResultType.PasswordMissingCharacterVariety)
    {
        <div class="alert alert-danger" role="alert">
            @Translate("The password must contain uppercase, lowercase, numbers and special characters")
        </div>
    } 
    else if (Model.Result == UserChangePasswordResultType.Success)
    {
        <div class="alert alert-success" role="alert">
            @Translate("Password changed")
        </div>
    } 
    else if (Model.Result != UserChangePasswordResultType.None)
    {
       <div class="alert alert-danger">@Translate(Model.Result.ToString())</div>
    }

    <form method="post">
        <input type="hidden" name="UserOldPassword" value="true"/>

        <div class="form-floating mb-3">
            <input type="password" name="OldPassword" id="OldPassword" class="form-control" placeholder="@Translate("Old password")" required>
            <label for="OldPassword">@Translate("Old Password")</label>
        </div>

        <div class="form-floating mb-3">
            <input type="password" name="NewPassword" id="NewPassword" class="form-control" placeholder="@Translate("New password")" required>
            <label for="NewPassword">@Translate("New password")</label>
        </div>

        <div class="form-floating mb-3">
            <input type="password" name="ConfirmNewPassword" id="ConfirmNewPassword" class="form-control" placeholder="@Translate("Confirm new password")" required>
            <label for="ConfirmNewPassword">@Translate("Confirm new password")</label>
        </div>

        <button type="submit" name="cmd" value="ChangePassword" class="btn btn-primary w-100" data-dw-button="primary" id="PasswordRecoveryButton">@Translate("Change password")</button>
    </form>     
</div>

