initial commit
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
@page "/account/logout"
|
||||
@layout AuthenticationLayout
|
||||
|
||||
@using Indotalent.Shared.Consts
|
||||
@using Microsoft.JSInterop
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<PageTitle>Sign Out - @GlobalConsts.AppInitial</PageTitle>
|
||||
|
||||
<style>
|
||||
.logout-container {
|
||||
text-align: center;
|
||||
padding: 0.5rem 0;
|
||||
}
|
||||
.logout-icon-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.logout-icon-circle {
|
||||
background: #EEECFA;
|
||||
border-radius: 50%;
|
||||
padding: 1.25rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #594AE2;
|
||||
}
|
||||
.logout-icon-circle .mud-icon-root {
|
||||
font-size: 3rem;
|
||||
}
|
||||
.logout-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.logout-desc {
|
||||
font-size: 0.875rem;
|
||||
color: #64748b;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
.btn-signout {
|
||||
text-transform: none;
|
||||
border-radius: 0.5rem;
|
||||
height: 48px;
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
letter-spacing: 0;
|
||||
background-color: #594AE2;
|
||||
color: white;
|
||||
}
|
||||
.btn-signout:hover {
|
||||
background-color: #4235B8;
|
||||
}
|
||||
.btn-cancel {
|
||||
text-transform: none;
|
||||
color: #94a3b8;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="logout-container">
|
||||
<div class="logout-icon-wrapper">
|
||||
<div class="logout-icon-circle">
|
||||
<MudIcon Icon="@Icons.Material.Filled.ExitToApp" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logout-title">Sign Out</div>
|
||||
<div class="logout-desc">Are you sure you want to sign out of your account?</div>
|
||||
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Size="Size.Large"
|
||||
FullWidth="true"
|
||||
Disabled="@isLoggingOut"
|
||||
OnClick="Logout"
|
||||
Class="btn-signout">
|
||||
@if (isLoggingOut)
|
||||
{
|
||||
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true" />
|
||||
<span class="ms-2">Processing...</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Sign Out</span>
|
||||
}
|
||||
</MudButton>
|
||||
|
||||
<MudButton Variant="Variant.Text"
|
||||
Class="mt-3 btn-cancel"
|
||||
FullWidth="true"
|
||||
Href="/account/tenant-selection"
|
||||
Disabled="@isLoggingOut">
|
||||
Cancel
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private bool isLoggingOut;
|
||||
|
||||
private async Task Logout()
|
||||
{
|
||||
isLoggingOut = true;
|
||||
StateHasChanged();
|
||||
|
||||
var result = await JSRuntime.InvokeAsync<ApiJSRuntimeResponse>("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; }
|
||||
}
|
||||
}
|
||||
|
||||
<script>
|
||||
window.apiAccountLogout = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/account/signout', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Unknown error occurred');
|
||||
}
|
||||
return { status: 200, title: 'Success user logout' };
|
||||
} catch (error) {
|
||||
return { status: 500, title: 'Server / Network error' };
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user