@using LyricsFinder.NET.Areas.Identity.Models;
@using Microsoft.AspNetCore.Identity
@inject SignInManager<CustomAppUserData> SignInManager
@inject UserManager<CustomAppUserData> UserManager

<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
    <ul class="navbar-nav">
        @if (SignInManager.IsSignedIn(User))
        {
            <li class="nav-item" style="align-self: center;">
                @if (UserManager.GetUserAsync(User).Result!.ProfilePicture != null)
                {
                    <img style="width:40px;height:40px; object-fit:cover; border-radius:30px" src="data:image/*;base64,@(Convert.ToBase64String(UserManager.GetUserAsync(User).Result!.ProfilePicture!))">
                }
            </li>

            <li class="nav-item">
                <a class="nav-link text-primary" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity!.Name!</a>
            </li>

            @if (User.IsInRole("Admin") || User.IsInRole("Moderator"))
            {
                <li class="nav-item">
                    <a class="nav-link text-dark" asp-area="" asp-controller="RoleManager" asp-action="Index">Role Manager</a>
                </li>
            }

            <li class="nav-item">
                <form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })" method="post">
                    <button type="submit" class="nav-link btn btn-link text-dark">Logout</button>
                </form>
            </li>
        }
        else
        {
            <li class="nav-item">
                <a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Register">Register</a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Login">Login</a>
            </li>
        }
    </ul>
</div>
