@using Indotalent.ConfigBackEnd.Extensions @using Indotalent.Features.Organization.EmployeeGroup @using Indotalent.Features.Organization.EmployeeGroup.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject EmployeeGroupService EmployeeGroupService @inject ISnackbar Snackbar
@(ReadOnly ? "Employee Group Details" : "Edit Employee Group") @(ReadOnly ? "Viewing employee segment specification." : "Modify existing segment information.")
Group Name Description Audit History Created At@DateTimeExtensions.ToString(_model.CreatedAt) Created By@(!string.IsNullOrEmpty(_model.CreatedBy) ? _model.CreatedBy : "System") Last Updated At@DateTimeExtensions.ToString(_model.UpdatedAt) Last Updated By@(!string.IsNullOrEmpty(_model.UpdatedBy) ? _model.UpdatedBy : "System")
@(ReadOnly ? "Back to List" : "Cancel") @if (!ReadOnly) { @if (_processing) { Updating... } else { Save Changes } }
@code { [Parameter] public UpdateEmployeeGroupRequest 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 UpdateEmployeeGroupValidator _validator = new(); private UpdateEmployeeGroupRequest _model = new(); private bool _processing = false; protected override void OnInitialized() { _model = Data; } private async Task Submit() { if (ReadOnly) return; await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await EmployeeGroupService.UpdateEmployeeGroupAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Employee group updated successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }