@using Indotalent.Features.Organization.Employee @using Indotalent.Features.Organization.Employee.Cqrs @using Features.Root.Shared @using MudBlazor @inject EmployeeService EmployeeService @inject IDialogService DialogService @inject ISnackbar Snackbar
Employee Income Details Manage income components for @EmployeeName @(!string.IsNullOrEmpty(_displayCode) ? $"({_displayCode})" : "")
List of Incomes Add Income
@if (_isLoading) {
} else if (!_incomes.Any()) {
No income components assigned for this employee.
} else { Income Component Type Amount Description Status Actions @context.IncomeName @context.IncomeType @context.Amount.ToString("N0") @context.Description
}
@code { [Parameter] public string EmployeeId { get; set; } = string.Empty; [Parameter] public string EmployeeName { get; set; } = string.Empty; [Parameter] public string EmployeeCode { get; set; } = string.Empty; [Parameter] public EventCallback OnBack { get; set; } private List _incomes = new(); private bool _isLoading = true; private string _displayCode = string.Empty; protected override async Task OnInitializedAsync() { _displayCode = EmployeeCode; await LoadData(); } private async Task LoadData() { _isLoading = true; StateHasChanged(); var response = await EmployeeService.GetEmployeeIncomeListAsync(EmployeeId); if (response?.IsSuccess == true) { _incomes = response.Value ?? new(); if (_incomes.Any() && string.IsNullOrEmpty(_displayCode)) { _displayCode = _incomes.First().EmployeeCode ?? string.Empty; } } _isLoading = false; StateHasChanged(); } private async Task OnAdd() { var parameters = new DialogParameters { ["EmployeeId"] = EmployeeId }; var options = new DialogOptions { CloseButton = true, BackdropClick = false }; var dialog = await DialogService.ShowAsync<_EmployeeIncomeCreateForm>("Add Employee Income", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await LoadData(); } private async Task OnEdit(GetEmployeeIncomeListResponse context) { var parameters = new DialogParameters { ["Id"] = context.Id }; var options = new DialogOptions { CloseButton = true, BackdropClick = false }; var dialog = await DialogService.ShowAsync<_EmployeeIncomeUpdateForm>("Edit Employee Income", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await LoadData(); } private async Task OnDelete(GetEmployeeIncomeListResponse context) { var dialog = await DialogService.ShowAsync<_DeleteConfirmation>("", new DialogParameters<_DeleteConfirmation> { { x => x.ContentText, $"{context.IncomeName} from {EmployeeName}" } }); var result = await dialog.Result; if (result != null && !result.Canceled) { var success = await EmployeeService.DeleteEmployeeIncomeByIdAsync(context.Id!); if (success) { Snackbar.Add("Income component removed", Severity.Success); await LoadData(); } } } }