27 lines
1.1 KiB
Plaintext
27 lines
1.1 KiB
Plaintext
@page "/payroll/deduction"
|
|
@using Indotalent.Features.Payroll.Deduction.Cqrs
|
|
@using MudBlazor
|
|
|
|
@if (_currentView == ViewMode.Create)
|
|
{
|
|
<_DeductionCreateForm OnCancel="BackToTable" OnSuccess="HandleSuccess" />
|
|
}
|
|
else if (_currentView == ViewMode.Update || _currentView == ViewMode.View)
|
|
{
|
|
<_DeductionUpdateForm Data="_selectedData!" ReadOnly="@(_currentView == ViewMode.View)" OnCancel="BackToTable" OnSuccess="HandleSuccess" />
|
|
}
|
|
else
|
|
{
|
|
<_DeductionDataTable OnAdd="ShowCreate" OnEdit="(item) => ShowUpdate(item, false)" OnView="(item) => ShowUpdate(item, true)" />
|
|
}
|
|
|
|
@code {
|
|
private enum ViewMode { Table, Create, Update, View }
|
|
private ViewMode _currentView = ViewMode.Table;
|
|
private UpdateDeductionRequest? _selectedData;
|
|
|
|
private void ShowCreate() => _currentView = ViewMode.Create;
|
|
private void ShowUpdate(UpdateDeductionRequest data, bool readOnly) { _selectedData = data; _currentView = readOnly ? ViewMode.View : ViewMode.Update; }
|
|
private void BackToTable() => _currentView = ViewMode.Table;
|
|
private void HandleSuccess() => _currentView = ViewMode.Table;
|
|
} |