using eNavigator.Routes;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System.Text;

namespace eNavigator.Pages
{
    public partial class Counter : ComponentBase
    {
        private int currentCount = 0;

        private void IncrementCount()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("Hello");
            currentCount++;
        }

        [Inject]
        private NavigationManager NavigationManager { get; set; } = default!;

        [Inject]
        private AuthenticationStateProvider authenticationStateProvider { get; set; } = default;

        protected override async Task OnInitializedAsync()
        {
          AuthenticationState authenticationState = await authenticationStateProvider.GetAuthenticationStateAsync();
          if(!authenticationState.User.Identity.IsAuthenticated)
          {
            NavigationManager.NavigateTo(PageRoute.Login);
          }
        }        
    }
}