@using Indotalent.Features.Payroll.Income @using Indotalent.Features.Payroll.Income.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject IncomeService IncomeService @inject ISnackbar Snackbar
Add Income Component Define new earning element for payroll processing.
Component Code Component Name Income Type Fixed Variable Tax Treatment
Calculation Base Status Active Inactive Description
Cancel @if (_processing) { Processing... } else { Create Component }
@code { [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private CreateIncomeValidator _validator = new(); private CreateIncomeRequest _model = new() { Type = "Fixed", Status = "Active", IsTaxable = true }; private bool _processing = false; private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await IncomeService.CreateIncomeAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Income component created successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } catch (Exception ex) { Snackbar.Add($"Error: {ex.Message}", Severity.Error); } finally { _processing = false; } } }