// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; namespace MagMan.UI.Shared { public partial class NavMenu { [CascadingParameter] private Task AuthenticationStateTask { get; set; } private bool collapseNavMenu = true; private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; protected bool showText { get; set; } = true; private string userName = ""; protected override async Task OnInitializedAsync() { var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); var user = authState.User; if (user.Identity.IsAuthenticated) { userName = $"{user.Identity.Name}"; } else { userName = "Non Autenticato"; } } private void ToggleNavMenu() { collapseNavMenu = !collapseNavMenu; } protected string hideText { get => showText ? "" : "invisible"; } [Parameter] public EventCallback EC_compressUpdated { get; set; } #if DEBUG protected bool isDebug = true; #else protected bool isDebug = false; #endif } }