@inject NavigationManager NavigationManager

<AuthorizeView>
    <Authorized>
        <MudMenu @ref="_menu" ActivationEvent="@MouseEvent.LeftClick" Dense="true" Class="ml-4" AnchorOrigin="Origin.TopRight" TransformOrigin="Origin.TopRight">
            <ActivatorContent>
                @if (string.IsNullOrEmpty(""))
                {
                    <MudAvatar Square Variant="Variant.Filled" Color="Color.Dark">
                        @context.User.Identity?.Name?.FirstOrDefault()
                    </MudAvatar>
                }
                else
                {
                    <MudImage Src="" />
                }
            </ActivatorContent>
        <ChildContent>
            <MudCard Elevation="0" Square="true" Class="mt-n2">
                <MudCardHeader>
                    <CardHeaderAvatar>
                        @if (string.IsNullOrEmpty(""))
                        {
                            <MudAvatar Square Variant="Variant.Filled" Color="Color.Dark">
                                @context.User.Identity?.Name?.FirstOrDefault()
                            </MudAvatar>
                        }
                        else
                        {
                            <MudAvatar Image="" />
                        }
                    </CardHeaderAvatar>
                    <CardHeaderContent>
                        <MudText Typo="Typo.body2">@context.User.Identity?.Name</MudText>
                        @*<MudText Typo="Typo.caption">@context.User.Identity?.Name!</MudText>*@
                    </CardHeaderContent>
                </MudCardHeader>
            </MudCard>
            @*<MudDivider Class="mb-2" />*@
            <MudListItem Text="Profile" OnClick="@(s=>OnProfile())" Icon="@Icons.Material.Outlined.Person" />
            <MudListItem Text="Logout" OnClick="@(s=>OnLogout())" Icon="@Icons.Material.Filled.Logout" />
        </ChildContent>
        </MudMenu>
    </Authorized>
    <NotAuthorized>
        <MudIconButton Icon="@Icons.Material.Outlined.Login" Color="Color.Inherit" Class="ml-3" OnClick="@(s=>OnLogin())" />
    </NotAuthorized>
</AuthorizeView>

@code{
    private MudMenu? _menu;

    private void OnLogin()
    {
        _menu?.CloseMenu();
        NavigationManager.NavigateTo(Navigation.Account.Login, false);
    }

    private void OnLogout()
    {
        _menu?.CloseMenu();
        NavigationManager.NavigateTo(Navigation.Account.Logout, true);
    }

    private void OnProfile()
    {
        _menu?.CloseMenu();
        NavigationManager.NavigateTo(Navigation.Account.Profile, false);
    }
}