@using Indotalent.ConfigBackEnd.Extensions @using Indotalent.Features.Organization.Employee @using Indotalent.Features.Organization.Employee.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @implements IDisposable @inject EmployeeService EmployeeService @inject ISnackbar Snackbar @(ReadOnly ? "Employee Profile" : "Edit Employee") Managing records for @_model.FirstName @_model.LastName @if (_isLoadingData) { Synchronizing Records... } else { BASIC IDENTITY Employee Code Salary Grade @foreach (var item in _lookupData.Grades) { @item.Name (@item.Code) Range: @item.SalaryFrom.ToString("N0") - @item.SalaryTo.ToString("N0") } First Name Middle Name Last Name PAYROLL & BANKING Basic Salary (Monthly) @if (!string.IsNullOrEmpty(_model.GradeId)) { var selectedGrade = _lookupData.Grades.FirstOrDefault(x => x.Id == _model.GradeId); if (selectedGrade != null) { Allowed range: @selectedGrade.SalaryFrom.ToString("N0") - @selectedGrade.SalaryTo.ToString("N0") } } Salary Bank Name Bank Account Name Bank Account Number PERSONAL DETAILS Place of Birth Date of Birth Gender Male Female Marital Status Religion Identity Number (KTP) Tax Number (NPWP) Blood Type Last Education ORGANIZATIONAL Branch @foreach (var item in _lookupData.Branches) { @item.Name } Department @foreach (var item in _lookupData.Departments) { @item.Name } Designation @foreach (var item in _lookupData.Designations) { @item.Name } Joined Date Resigned Date Employee Status Employment Type Job Description ADDRESS & CONTACT Email Phone Street Address City Province Zip Code SOCIAL MEDIA LinkedIn Instagram TikTok Facebook X (Twitter) ADDITIONAL Other Info 1 Other Info 2 Other Info 3 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 UpdateEmployeeRequest 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; private UpdateEmployeeRequest _model = new(); private UpdateEmployeeValidator _validator = new(); private LookupResponse _lookupData = new(); private bool _processing = false; private bool _isLoadingData = true; private bool _isDisposed = false; public void Dispose() => _isDisposed = true; protected override void OnInitialized() { _model = Data; } protected override async Task OnInitializedAsync() { try { _isLoadingData = true; var response = await EmployeeService.GetLookupAsync(); if (response?.IsSuccess == true) { _lookupData = response.Value ?? new(); } } finally { if (!_isDisposed) { _isLoadingData = false; StateHasChanged(); } } } private async Task Submit() { await _form!.Validate(); if (!_form.IsValid) return; _processing = true; try { var res = await EmployeeService.UpdateEmployeeAsync(_model); await Task.Delay(500); if (res?.IsSuccess == true) { Snackbar.Add("Updated successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }