@inject AuthenticationStateProvider Authentication

<div class="top-row pl-4 navbar navbar-dark">
    <a class="navbar-brand" href="">Client</a>
    <button class="navbar-toggler" @onclick="ToggleNavMenu">
        <span class="navbar-toggler-icon"></span>
    </button>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
    <ul class="nav flex-column">
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
                <span class="oi oi-home" aria-hidden="true"></span> Home
            </NavLink>
        </li>
        <AuthorizeView>
            <Authorized>
                <li class="nav-item px-3">
                    <NavLink class="nav-link" href="links/new">
                        <span class="oi oi-plus" aria-hidden="true"></span> Publish a new link
                    </NavLink>
                </li>
                <li class="nav-item px-3">
                    <button @onclick="Logout">
                        Sign out
                    </button>
                </li>
            </Authorized>
            <NotAuthorized>
                <li class="nav-item px-3">
                    <NavLink class="nav-link" href="login">
                        <span class="oi oi-plus" aria-hidden="true"></span> Sign in
                    </NavLink>
                </li>
            </NotAuthorized>
        </AuthorizeView>
        
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="counter">
                <span class="oi oi-plus" aria-hidden="true"></span> Counter
            </NavLink>
        </li>
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="fetchdata">
                <span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
            </NavLink>
        </li>
    </ul>
</div>

@code {
    private bool collapseNavMenu = true;

    private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }

    private Task Logout()
    {
        return ((JwtAuthStateProvider)Authentication).Logout();
    }
}
