273 lines
13 KiB
Plaintext
273 lines
13 KiB
Plaintext
@using Indotalent.ConfigBackEnd.Extensions
|
|
@using Indotalent.Features.Setting.SystemUser
|
|
@using Indotalent.Features.Setting.SystemUser.Cqrs
|
|
@using MudBlazor
|
|
@using Indotalent.Shared.Utils
|
|
@inject SystemUserService SystemUserService
|
|
@inject ISnackbar Snackbar
|
|
|
|
<MudPaper Elevation="0" Square="true" Class="pa-6 mb-3 d-flex align-center justify-space-between" Style="border: 1px solid #DCEBFA;">
|
|
<div class="d-flex align-center gap-4">
|
|
<MudIconButton Icon="@Icons.Material.Filled.ArrowBack" OnClick="() => OnCancel.InvokeAsync()" />
|
|
<div>
|
|
<MudText Typo="Typo.h5" Style="font-weight: 900; color: #1a1a1a;">@(ReadOnly ? "User Details" : "Edit User")</MudText>
|
|
<MudText Typo="Typo.body2" Style="color: #64748b;">@(ReadOnly ? "View complete user account information." : "Update account details and security settings.")</MudText>
|
|
</div>
|
|
</div>
|
|
</MudPaper>
|
|
|
|
<MudPaper Elevation="0" Outlined="true" Class="pa-8" Style="border-radius: 4px; border: 1px solid #DCEBFA;">
|
|
<MudForm @ref="_form" Model="_model" Validation="@(_validator.ValidateValue())">
|
|
<MudGrid Spacing="3">
|
|
<MudItem xs="12">
|
|
<MudText Typo="Typo.button" Color="Color.Primary" Style="font-weight: 800;">Primary Information</MudText>
|
|
<MudDivider Class="mt-2 mb-4" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Full Name</MudText>
|
|
<MudTextField @bind-Value="_model.FullName"
|
|
For="@(() => _model.FullName)"
|
|
ReadOnly="ReadOnly"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Email Address & Username</MudText>
|
|
<MudTextField Value="_model.Email"
|
|
ReadOnly="true"
|
|
Variant="Variant.Outlined"
|
|
Margin="Margin.Dense"
|
|
FullWidth="true"
|
|
Style="background-color: #f5f5f5; color: #757575;" />
|
|
<MudText Typo="Typo.caption" Style="color: #64748b;" Class="mt-1 d-block">
|
|
Email and Username cannot be changed. Username is linked to the email address.
|
|
</MudText>
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Phone Number</MudText>
|
|
<MudTextField @bind-Value="_model.PhoneNumber"
|
|
For="@(() => _model.PhoneNumber)"
|
|
ReadOnly="ReadOnly"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudText Typo="Typo.button" Color="Color.Primary" Class="mt-4" Style="font-weight: 800;">SSO Identifiers</MudText>
|
|
<MudDivider Class="mt-2 mb-4" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Firebase ID</MudText>
|
|
<MudTextField @bind-Value="_model.SsoIdFirebase" For="@(() => _model.SsoIdFirebase)" ReadOnly="ReadOnly" Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Keycloak ID</MudText>
|
|
<MudTextField @bind-Value="_model.SsoIdKeycloak" For="@(() => _model.SsoIdKeycloak)" ReadOnly="ReadOnly" Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Azure ID</MudText>
|
|
<MudTextField @bind-Value="_model.SsoIdAzure" For="@(() => _model.SsoIdAzure)" ReadOnly="ReadOnly" Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">AWS ID</MudText>
|
|
<MudTextField @bind-Value="_model.SsoIdAws" For="@(() => _model.SsoIdAws)" ReadOnly="ReadOnly" Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Other SSO ID 1</MudText>
|
|
<MudTextField @bind-Value="_model.SsoIdOther1" For="@(() => _model.SsoIdOther1)" ReadOnly="ReadOnly" Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Other SSO ID 2</MudText>
|
|
<MudTextField @bind-Value="_model.SsoIdOther2" For="@(() => _model.SsoIdOther2)" ReadOnly="ReadOnly" Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Other SSO ID 3</MudText>
|
|
<MudTextField @bind-Value="_model.SsoIdOther3" For="@(() => _model.SsoIdOther3)" ReadOnly="ReadOnly" Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudText Typo="Typo.button" Color="Color.Primary" Class="mt-4" Style="font-weight: 800;">Account Settings & Status</MudText>
|
|
<MudDivider Class="mt-2 mb-4" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="6">
|
|
<MudStack Spacing="4">
|
|
<div>
|
|
<MudSwitch @bind-Value="_model.IsActive" Color="Color.Success" Label="Is Active" ReadOnly="ReadOnly" />
|
|
<MudText Typo="Typo.caption" Class="ml-10 d-block mt-n2" Style="color: #64748b;">General availability of the account in the system.</MudText>
|
|
</div>
|
|
|
|
<div>
|
|
<MudSwitch @bind-Value="_model.EmailConfirmed" Color="Color.Info" Label="Email Confirmed" ReadOnly="ReadOnly" />
|
|
<MudText Typo="Typo.caption" Class="ml-10 d-block mt-n2" Style="color: #64748b;">Current status of email verification.</MudText>
|
|
</div>
|
|
|
|
<div>
|
|
<MudSwitch @bind-Value="_model.PhoneNumberConfirmed" Color="Color.Info" Label="Phone Confirmed" ReadOnly="ReadOnly" />
|
|
<MudText Typo="Typo.caption" Class="ml-10 d-block mt-n2" Style="color: #64748b;">Current status of phone number verification.</MudText>
|
|
</div>
|
|
|
|
<div>
|
|
<MudSwitch @bind-Value="_model.TwoFactorEnabled" Color="Color.Warning" Label="Enable 2FA" ReadOnly="ReadOnly" />
|
|
<MudText Typo="Typo.caption" Class="ml-10 d-block mt-n2" Style="color: #64748b;">Requirement for Two-Factor Authentication.</MudText>
|
|
</div>
|
|
</MudStack>
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="6">
|
|
<MudStack Spacing="4">
|
|
<div>
|
|
<MudSwitch @bind-Value="_model.LockoutEnabled" Color="Color.Error" Label="Lockout Enabled" ReadOnly="ReadOnly" />
|
|
<MudText Typo="Typo.caption" Class="ml-10 d-block mt-n2" Style="color: #64748b;">Allow account to be locked after failed attempts.</MudText>
|
|
</div>
|
|
|
|
<div class="mt-2">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Lockout Until</MudText>
|
|
<MudDatePicker @bind-Date="_lockoutDate"
|
|
Placeholder="@(ReadOnly ? "No Lockout" : "Select Date")"
|
|
Variant="Variant.Outlined"
|
|
Margin="Margin.Dense"
|
|
Editable="!ReadOnly"
|
|
Clearable="!ReadOnly"
|
|
ReadOnly="ReadOnly"
|
|
MinDate="DateTime.Today" />
|
|
<MudText Typo="Typo.caption" Style="color: #64748b;">Current account lockout expiration date.</MudText>
|
|
</div>
|
|
</MudStack>
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudText Typo="Typo.button" Color="Color.Primary" Class="mt-4" Style="font-weight: 800;">Audit History</MudText>
|
|
<MudDivider Class="mt-2 mb-4" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Created At</MudText>
|
|
<MudText Typo="Typo.body2" Style="color: #1a1a1a; font-weight: 600;">@DateTimeExtensions.ToString(_model.CreatedAt)</MudText>
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Last Login At</MudText>
|
|
<MudText Typo="Typo.body2" Style="color: #1a1a1a; font-weight: 600;">@DateTimeExtensions.ToString(_model.LastLoginAt)</MudText>
|
|
</MudItem>
|
|
|
|
<MudItem xs="12" sm="4">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Last Updated At</MudText>
|
|
<MudText Typo="Typo.body2" Style="color: #1a1a1a; font-weight: 600;">@DateTimeExtensions.ToString(_model.UpdatedAt)</MudText>
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
<div class="d-flex justify-end gap-2 mt-8">
|
|
<MudButton OnClick="() => OnCancel.InvokeAsync()"
|
|
Variant="Variant.Outlined"
|
|
Disabled="_processing"
|
|
Style="border-radius: 4px; text-transform: none; font-weight: 700;border: 1px solid #e0e0e0;">
|
|
@(ReadOnly ? "Back to List" : "Cancel")
|
|
</MudButton>
|
|
@if (!ReadOnly)
|
|
{
|
|
<MudButton Color="Color.Primary"
|
|
Variant="Variant.Filled"
|
|
OnClick="Submit"
|
|
Disabled="_processing"
|
|
Style="border-radius: 4px; text-transform: none; font-weight: 700;">
|
|
@if (_processing)
|
|
{
|
|
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true" />
|
|
<MudText Class="ms-2" Typo="Typo.button" Style="text-transform: none !important;">Processing...</MudText>
|
|
}
|
|
else
|
|
{
|
|
<MudText>Save Changes</MudText>
|
|
}
|
|
</MudButton>
|
|
}
|
|
</div>
|
|
</MudForm>
|
|
</MudPaper>
|
|
|
|
@code {
|
|
[Parameter] public UpdateSystemUserRequest Data { get; set; } = new();
|
|
[Parameter] public bool ReadOnly { get; set; } = false;
|
|
[Parameter] public EventCallback OnCancel { get; set; }
|
|
[Parameter] public EventCallback OnSuccess { get; set; }
|
|
|
|
private MudForm _form = default!;
|
|
private UpdateSystemUserRequest _model = new();
|
|
private UpdateSystemUserValidator _validator = new();
|
|
private DateTime? _lockoutDate;
|
|
private bool _processing = false;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
_model = new UpdateSystemUserRequest
|
|
{
|
|
Id = Data.Id,
|
|
UserName = Data.UserName,
|
|
FullName = Data.FullName,
|
|
Email = Data.Email,
|
|
PhoneNumber = Data.PhoneNumber,
|
|
EmailConfirmed = Data.EmailConfirmed,
|
|
PhoneNumberConfirmed = Data.PhoneNumberConfirmed,
|
|
TwoFactorEnabled = Data.TwoFactorEnabled,
|
|
IsActive = Data.IsActive,
|
|
LockoutEnabled = Data.LockoutEnabled,
|
|
LockoutEnd = Data.LockoutEnd,
|
|
SsoIdFirebase = Data.SsoIdFirebase,
|
|
SsoIdKeycloak = Data.SsoIdKeycloak,
|
|
SsoIdAzure = Data.SsoIdAzure,
|
|
SsoIdAws = Data.SsoIdAws,
|
|
SsoIdOther1 = Data.SsoIdOther1,
|
|
SsoIdOther2 = Data.SsoIdOther2,
|
|
SsoIdOther3 = Data.SsoIdOther3,
|
|
CreatedAt = Data.CreatedAt,
|
|
LastLoginAt = Data.LastLoginAt,
|
|
UpdatedAt = Data.UpdatedAt
|
|
};
|
|
|
|
if (_model.LockoutEnd.HasValue)
|
|
{
|
|
_lockoutDate = _model.LockoutEnd.Value.DateTime;
|
|
}
|
|
}
|
|
|
|
private async Task Submit()
|
|
{
|
|
if (ReadOnly) return;
|
|
|
|
await _form.Validate();
|
|
if (!_form.IsValid) return;
|
|
|
|
_processing = true;
|
|
try
|
|
{
|
|
if (_lockoutDate.HasValue)
|
|
{
|
|
_model.LockoutEnd = new DateTimeOffset(_lockoutDate.Value, TimeSpan.Zero);
|
|
}
|
|
else
|
|
{
|
|
_model.LockoutEnd = null;
|
|
}
|
|
|
|
var response = await SystemUserService.UpdateSystemUserAsync(_model);
|
|
await Task.Delay(500);
|
|
|
|
if (response != null && response.IsSuccess)
|
|
{
|
|
Snackbar.Add("User updated successfully", Severity.Success);
|
|
await OnSuccess.InvokeAsync();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"Error: {ex.Message}", Severity.Error);
|
|
}
|
|
finally
|
|
{
|
|
_processing = false;
|
|
}
|
|
}
|
|
} |