Files
blazor-cms/Features/Thirdparty/Patient/Components/PatientPage.razor
T
2026-07-21 13:52:43 +07:00

28 lines
1.2 KiB
Plaintext

@page "/thirdparty/patient"
@using Indotalent.Features.Thirdparty.Patient
@using Indotalent.Features.Thirdparty.Patient.Cqrs
@using Indotalent.Features.Thirdparty.Patient.Components
@using MudBlazor
@if (_currentView == ViewMode.Create)
{
<_PatientCreateForm OnCancel="BackToTable" OnSuccess="HandleSuccess" />
}
else if (_currentView == ViewMode.Update || _currentView == ViewMode.View)
{
<_PatientUpdateForm Data="_selectedData!" ReadOnly="@(_currentView == ViewMode.View)" OnCancel="BackToTable" OnSuccess="HandleSuccess" />
}
else
{
<_PatientDataTable 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 UpdatePatientRequest? _selectedData;
private void ShowCreate() => _currentView = ViewMode.Create;
private void ShowUpdate(UpdatePatientRequest 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; }
}