using System.Threading.Tasks;
using DiplomovaPrace.Contracts.Security.ViewModels;
using DiplomovaPrace.Web.Admin.Infrastructure;
using Microsoft.AspNetCore.Components;

namespace DiplomovaPrace.Web.Admin.Shared.Layout
{
	public partial class MySideBar
	{
		[Inject]
		private JwtAuthenticationStateProvider JwtAuthenticationStateProvider { get; set; }

		public string FirstName { get; set; }

		public string LastName { get; set; }

		protected override async Task OnInitializedAsync()
		{
			await base.OnInitializedAsync().ConfigureAwait(false);

			JwtVM jwtVM = await JwtAuthenticationStateProvider.GetJwtTokenVMAsync().ConfigureAwait(false);

			if (jwtVM is not null)
			{
				FirstName = jwtVM.FirstName ?? "";
				LastName = jwtVM.LastName ?? "";
			}
		}
	}
}
