@using TIAMWebApp.Shared.Application.Interfaces
@using AyCode.Interfaces.StorageHandlers;
@inject ISecureStorageHandler SecureStorageHandler

<div class="top-row ps-3 navbar navbar-light">
    <div class="container-fluid">
        <button title="Back button" class="my-back-button" style="display:none" @onclick="NavigateBack">
            <img src="_content/TIAMSharedUI/images/navbar-toggler.png" width="40" />
        </button>
        <a class="navbar-brand my-navbar-brand" href=""></a>
        <button title="Navigation menu" class="navbar-toggler my-navbar-toggler" @onclick="ToggleNavMenu">
            <img src="_content/TIAMSharedUI/images/navbar-toggler.png" width="40" />
        </button>

    </div>


</div>

<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
    <div style="display: flex; align-content: center; justify-content:center" class="my-navbar-hero">

        <a class="navbar-brand my-navbar-brand" href=""><img src="_content/TIAMSharedUI/images/logo_wide.png" alt="TourIam Logo" title="TourIAm Logo" /></a>

    </div>
    <nav class="flex-column">
        <div class="nav-item px-3">
            <NavLink class="nav-link" href="index">
                Home
            </NavLink>
        </div>
        

        <div class="nav-item px-3">
            <NavLink class="nav-link" href="user/properties">
                Properties
            </NavLink>
        </div>

        <div class="nav-item px-3">
            <NavLink class="nav-link" href="user/cards">
                Cards
            </NavLink>
        </div>

        <div class="nav-item px-3">
            <NavLink class="nav-link" @onclick="()=>expandSysAdminNav = !expandSysAdminNav">
                <span class="oi oi-list-rich" aria-hidden="true"></span> System Admin
            </NavLink>
        </div>
        @if (expandSysAdminNav)
        {
            <hr />
            <div class="nav-item px-3">
                <NavLink class="nav-link" href="user/admin">
                    Dashboard
                </NavLink>
            </div>
            <div class="nav-item px-3">
                <NavLink class="nav-link" href="user/transfers">
                    Transfers
                </NavLink>
            </div>
            <div class="nav-item px-3">
                <NavLink class="nav-link" href="user/destinations">
                    Destinations
                </NavLink>
            </div>
            
            <hr />
        }

        <div class="nav-item px-3">
            <NavLink class="nav-link" @onclick="()=>expandHotelAdminNav = !expandHotelAdminNav">
                <span class="oi oi-list-rich" aria-hidden="true"></span> Hotel Admin
            </NavLink>
        </div>
        @if (expandHotelAdminNav)
        {
            <hr />
            <div class="nav-item px-3">
                <NavLink class="nav-link" href="user/hoteladmin">
                    Hotel Dashboard
                </NavLink>
            </div>
            <div class="nav-item px-3">
                <NavLink class="nav-link" href="user/serviceprovider/5453-a87f77787d-khj899">
                    Manage
                </NavLink>
            </div>
            <div class="nav-item px-3">
                <NavLink class="nav-link" href="serviceprovider">
                    Public profile
                </NavLink>
            </div>
            <div class="nav-item px-3">
                <NavLink class="nav-link" href="counter">
                    My earnings
                </NavLink>
            </div>
            <hr />
        }


        
        
        <div class="nav-item px-3">
            <NavLink class="nav-link" href="user/profile">
                Profile
            </NavLink>
        </div>
        
        
        
        <div class="nav-item px-3">
            <NavLink class="nav-link" href="#" @onclick="SignOut">
                Signout
            </NavLink>
        </div>
    </nav>
</div>

@code {
    private bool collapseNavMenu = true;
    private bool expandSysAdminNav = false;
    private bool expandHotelAdminNav = false;
    private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

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

    private void NavigateBack()
    {

    }

    private void SignOut()
    {
        SecureStorageHandler.ClearAllSecureStorageAsync();
    }

}
