@page "/PersonalInfo" @attribute [Authorize] @using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.SingleElements @using salesbook.Shared.Core.Authorization.Enum @using salesbook.Shared.Core.Dto.PageState @using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface.System.Network @using salesbook.Shared.Core.Services @inject AppAuthenticationStateProvider AuthenticationStateProvider @inject INetworkService NetworkService @inject IFormFactor FormFactor @inject UserListState UserState @if (IsLoggedIn) {
@UtilityString.ExtractInitials(UserSession.User.Fullname)
@UserSession.User.Fullname @if (UserSession.User.KeyGroup is not null) { @(((KeyGroupEnum)UserSession.User.KeyGroup).ConvertToHumanReadable()) }
Sincronizza @*
*@ @* Ripristina dati *@
Esci
} @code { private bool Unavailable { get; set; } private bool IsLoggedIn { get; set; } private DateTime LastSync { get; set; } protected override async Task OnInitializedAsync() { IsLoggedIn = await UserSession.IsLoggedIn(); await LoadData(); } private async Task LoadData() { await Task.Run(() => { Unavailable = FormFactor.IsWeb() || !NetworkService.ConnectionAvailable; LastSync = LocalStorage.Get("last-sync"); }); StateHasChanged(); } private void OpenSettings() => NavigationManager.NavigateTo("/settings/Profilo"); private async Task Logout() { await AuthenticationStateProvider.SignOut(); IsLoggedIn = await UserSession.IsLoggedIn(); StateHasChanged(); } private void UpdateDb(bool withData = false) { LocalStorage.Remove("last-user-sync"); UserState.IsLoaded = false; UserState.IsLoading = false; NavigationManager.NavigateTo(withData ? $"/sync/{DateTime.Today:yyyy-MM-dd}" : "/sync", replace: true); } }