133 lines
6.1 KiB
Plaintext
133 lines
6.1 KiB
Plaintext
@using Indotalent.Features.Payroll.Grade
|
|
@using Indotalent.Features.Payroll.Grade.Cqrs
|
|
@using Indotalent.Shared.Utils
|
|
@using MudBlazor
|
|
@inject GradeService GradeService
|
|
@inject ISnackbar Snackbar
|
|
|
|
<MudPaper Elevation="0" Square="true" Class="pa-6 mb-3 d-flex align-center justify-space-between" Style="border: 1px solid #DCEBFA;">
|
|
<div class="d-flex align-center gap-4">
|
|
<MudIconButton Icon="@Icons.Material.Filled.ArrowBack" OnClick="() => OnCancel.InvokeAsync()" />
|
|
<div>
|
|
<MudText Typo="Typo.h5" Style="font-weight: 900; color: #1a1a1a;">Add New Grade</MudText>
|
|
<MudText Typo="Typo.body2" Style="color: #64748b;">Set up salary structure and overtime eligibility for a new pay grade.</MudText>
|
|
</div>
|
|
</div>
|
|
</MudPaper>
|
|
|
|
<MudPaper Elevation="0" Outlined="true" Class="pa-8" Style="border-radius: 0px; border: 1px solid #DCEBFA;">
|
|
<MudForm @ref="_form" Model="_model">
|
|
<MudGrid Spacing="3">
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Grade Code</MudText>
|
|
<MudTextField @bind-Value="_model.Code"
|
|
For="@(() => _model.Code)"
|
|
Validation="@(_validator.ValidateValue())"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" Placeholder="e.g. MGT-01" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Grade Name</MudText>
|
|
<MudTextField @bind-Value="_model.Name"
|
|
For="@(() => _model.Name)"
|
|
Validation="@(_validator.ValidateValue())"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" Placeholder="e.g. Senior Manager" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Salary From (Monthly)</MudText>
|
|
<MudNumericField @bind-Value="_model.SalaryFrom"
|
|
For="@(() => _model.SalaryFrom)"
|
|
HideSpinButtons="true"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Salary To (Monthly)</MudText>
|
|
<MudNumericField @bind-Value="_model.SalaryTo"
|
|
For="@(() => _model.SalaryTo)"
|
|
HideSpinButtons="true"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" FullWidth="true" />
|
|
</MudItem>
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Overtime Eligibility</MudText>
|
|
<div style="height: 40px; display: flex; align-items: center;">
|
|
<MudCheckBox @bind-Value="_model.IsOverTimeEligible" Label="Eligible for Overtime Pay" Color="Color.Primary" Dense="true" />
|
|
</div>
|
|
</MudItem>
|
|
<MudItem xs="12" sm="6">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Status</MudText>
|
|
<MudSelect @bind-Value="_model.Status"
|
|
For="@(() => _model.Status)"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true">
|
|
<MudSelectItem Value="@("Active")">Active</MudSelectItem>
|
|
<MudSelectItem Value="@("Inactive")">Inactive</MudSelectItem>
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="12">
|
|
<MudText Typo="Typo.subtitle2" Class="mb-1">Description</MudText>
|
|
<MudTextField @bind-Value="_model.Description"
|
|
For="@(() => _model.Description)"
|
|
Variant="Variant.Outlined" Margin="Margin.Dense" Lines="3" FullWidth="true" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
<div class="d-flex justify-end gap-2 mt-8">
|
|
<MudButton OnClick="() => OnCancel.InvokeAsync()"
|
|
Variant="Variant.Outlined"
|
|
Disabled="_processing"
|
|
Style="border: 1px solid #e0e0e0; border-radius: 4px; text-transform: none; font-weight: 700;">
|
|
Cancel
|
|
</MudButton>
|
|
<MudButton Color="Color.Primary"
|
|
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>Create Grade</MudText>
|
|
}
|
|
</MudButton>
|
|
</div>
|
|
</MudForm>
|
|
</MudPaper>
|
|
|
|
@code {
|
|
[Parameter] public EventCallback OnCancel { get; set; }
|
|
[Parameter] public EventCallback OnSuccess { get; set; }
|
|
|
|
private MudForm _form = default!;
|
|
private CreateGradeValidator _validator = new();
|
|
private CreateGradeRequest _model = new() { Status = "Active", IsOverTimeEligible = true };
|
|
private bool _processing = false;
|
|
|
|
private async Task Submit()
|
|
{
|
|
await _form.Validate();
|
|
if (!_form.IsValid) return;
|
|
|
|
_processing = true;
|
|
try
|
|
{
|
|
var response = await GradeService.CreateGradeAsync(_model);
|
|
await Task.Delay(500);
|
|
|
|
if (response != null && response.IsSuccess)
|
|
{
|
|
Snackbar.Add("Grade created successfully", Severity.Success);
|
|
await OnSuccess.InvokeAsync();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"Error: {ex.Message}", Severity.Error);
|
|
}
|
|
finally
|
|
{
|
|
_processing = false;
|
|
}
|
|
}
|
|
} |