@using PanoptesFrontend.Data;
@using PanoptesFrontend.Services;
@using System.Text.Json;
@inject IHttpService httpService

<div class="top-row ps-3 navbar navbar-dark">
    <div class="container-fluid">
        <a class="navbar-brand" href="">PanoptesFrontend</a>
        <button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
    <nav class="flex-column">
        @* @if (response != null)
        {
            @foreach (var module in response){
            <div class="nav-item px-3">
                <NavLink class="nav-link" href=@module.Name Match="NavLinkMatch.All">
                    <span class="oi oi-home" aria-hidden="true"></span> @module.Name
                </NavLink>
            </div>
            }
        } *@
    </nav>
</div>

@code {

    @* public Module[] response;

    protected override async Task OnInitializedAsync()
    {
        response = await httpService.GetAsync<Module[]>("http://localhost:10000/modules");
    } *@

    private bool collapseNavMenu = true;
    private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
    
    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }
}
