52 lines
1.4 KiB
Plaintext
52 lines
1.4 KiB
Plaintext
@page "/setting/currency"
|
|
@using Indotalent.Features.Setting.Currency
|
|
@using Indotalent.Features.Setting.Currency.Cqrs
|
|
@using MudBlazor
|
|
|
|
@if (_currentView == ViewMode.Create)
|
|
{
|
|
<_CurrencyCreateForm OnCancel="BackToTable"
|
|
OnSuccess="HandleSuccess" />
|
|
}
|
|
else if (_currentView == ViewMode.Update || _currentView == ViewMode.View)
|
|
{
|
|
<_CurrencyUpdateForm Data="_selectedData!"
|
|
ReadOnly="@(_currentView == ViewMode.View)"
|
|
OnCancel="BackToTable"
|
|
OnSuccess="HandleSuccess" />
|
|
}
|
|
else
|
|
{
|
|
<_CurrencyDataTable 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 UpdateCurrencyRequest? _selectedData;
|
|
|
|
private void ShowCreate()
|
|
{
|
|
_currentView = ViewMode.Create;
|
|
}
|
|
|
|
private void ShowUpdate(UpdateCurrencyRequest data, bool isReadOnly)
|
|
{
|
|
_selectedData = data;
|
|
_currentView = isReadOnly ? ViewMode.View : ViewMode.Update;
|
|
}
|
|
|
|
private void BackToTable()
|
|
{
|
|
_currentView = ViewMode.Table;
|
|
_selectedData = null;
|
|
}
|
|
|
|
private void HandleSuccess()
|
|
{
|
|
_currentView = ViewMode.Table;
|
|
_selectedData = null;
|
|
}
|
|
} |