@page "/account/logout" @layout AuthenticationLayout @using Indotalent.Shared.Consts @using Microsoft.JSInterop @inject IJSRuntime JSRuntime Sign Out - @GlobalConsts.AppInitial
Sign Out
Are you sure you want to sign out of your account?
@if (isLoggingOut) { Signing out... } else { Sign Out } Cancel
@code { private bool isLoggingOut; private async Task Logout() { isLoggingOut = true; StateHasChanged(); var result = await JSRuntime.InvokeAsync("apiAccountLogout"); if (result.Status == 200) { Snackbar.Add("Successfully signed out!", Severity.Success); await Task.Delay(500); Navigation.NavigateTo("/", forceLoad: true); } else { Snackbar.Add(result.Title ?? "Failed to logout.", Severity.Error); await Task.Delay(500); } isLoggingOut = false; StateHasChanged(); } private class ApiJSRuntimeResponse { public int? Status { get; set; } public string? Title { get; set; } } }