134 lines
5.5 KiB
Plaintext
134 lines
5.5 KiB
Plaintext
@using Indotalent.Features.Organization.Employee
|
|
@using Indotalent.Features.Organization.Employee.Cqrs
|
|
@using MudBlazor
|
|
@inject EmployeeService EmployeeService
|
|
@inject ISnackbar Snackbar
|
|
|
|
<style>
|
|
.field-label { font-size: 13px; font-weight: 700; color: #424242; margin-bottom: 4px; display: block; }
|
|
.section-header { font-weight: 800; color: #E65100; letter-spacing: 0.5px; margin-bottom: 8px; }
|
|
</style>
|
|
|
|
<MudDialog>
|
|
<TitleContent>
|
|
<MudText Typo="Typo.h6">
|
|
<MudIcon Icon="@Icons.Material.Filled.Add" Color="Color.Warning" Class="mr-3 mb-n1" />
|
|
Add Employee Deduction
|
|
</MudText>
|
|
</TitleContent>
|
|
<DialogContent>
|
|
<MudForm @ref="_form">
|
|
<MudStack Spacing="4">
|
|
<MudGrid Spacing="3">
|
|
<MudItem xs="12"><div class="section-header">DEDUCTION INFORMATION</div><MudDivider /></MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<label class="field-label">Deduction Component</label>
|
|
<MudSelect T="string"
|
|
@bind-Value="_model.DeductionId"
|
|
Required="true"
|
|
Variant="Variant.Outlined"
|
|
Margin="Margin.Dense"
|
|
Placeholder="Select component"
|
|
Dense="true"
|
|
AnchorOrigin="Origin.BottomCenter"
|
|
TransformOrigin="Origin.TopCenter">
|
|
@foreach (var item in _lookupData.Deductions)
|
|
{
|
|
<MudSelectItem Value="@item.Id">@item.Name (@item.Code)</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<label class="field-label">Amount</label>
|
|
<MudNumericField @bind-Value="_model.Amount"
|
|
Required="true"
|
|
Variant="Variant.Outlined"
|
|
Margin="Margin.Dense"
|
|
Format="N0"
|
|
HideSpinButtons="false"
|
|
Adornment="Adornment.Start"
|
|
AdornmentIcon="@Icons.Material.Filled.PriceCheck"
|
|
AdornmentColor="Color.Warning" />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<label class="field-label">Description</label>
|
|
<MudTextField @bind-Value="_model.Description"
|
|
Variant="Variant.Outlined"
|
|
Margin="Margin.Dense"
|
|
Lines="2"
|
|
Placeholder="Optional notes..." />
|
|
</MudItem>
|
|
|
|
<MudItem xs="12">
|
|
<MudCheckBox @bind-Value="_model.IsActive"
|
|
Label="Set as Active Component"
|
|
Color="Color.Warning"
|
|
Dense="true" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
</MudStack>
|
|
</MudForm>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<MudButton OnClick="Cancel" Variant="Variant.Outlined" Style="border: 1px solid #e0e0e0; border-radius: 4px; text-transform: none; font-weight: 700;">Cancel</MudButton>
|
|
<MudButton Color="Color.Warning"
|
|
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 Deduction</MudText>
|
|
}
|
|
</MudButton>
|
|
</DialogActions>
|
|
</MudDialog>
|
|
|
|
@code {
|
|
[CascadingParameter] IMudDialogInstance MudDialog { get; set; } = default!;
|
|
[Parameter] public string EmployeeId { get; set; } = string.Empty;
|
|
|
|
private MudForm? _form;
|
|
private CreateEmployeeDeductionRequest _model = new() { IsActive = true };
|
|
private LookupResponse _lookupData = new();
|
|
private bool _processing = false;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_model.EmployeeId = EmployeeId;
|
|
var response = await EmployeeService.GetLookupAsync();
|
|
if (response?.IsSuccess == true)
|
|
{
|
|
_lookupData = response.Value ?? new();
|
|
}
|
|
}
|
|
|
|
private async Task Submit()
|
|
{
|
|
await _form!.Validate();
|
|
if (!_form.IsValid) return;
|
|
|
|
_processing = true;
|
|
try
|
|
{
|
|
var res = await EmployeeService.CreateEmployeeDeductionAsync(_model);
|
|
await Task.Delay(500);
|
|
if (res?.IsSuccess == true)
|
|
{
|
|
Snackbar.Add("Deduction added successfully", Severity.Success);
|
|
MudDialog.Close(DialogResult.Ok(true));
|
|
}
|
|
}
|
|
finally { _processing = false; }
|
|
}
|
|
|
|
private void Cancel() => MudDialog.Cancel();
|
|
} |