@using Indotalent.ConfigBackEnd.Extensions @using Indotalent.Features.Thirdparty.PatientGroup @using Indotalent.Features.Thirdparty.PatientGroup.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject PatientGroupService PatientGroupService @inject ISnackbar Snackbar @(ReadOnly ? "Patient Group Details" : "Edit Patient Group") @(ReadOnly ? "Viewing patient segment specification." : "Modify existing segment information.") Group Name Description Audit History Created At@DateTimeExtensions.ToString(_model.CreatedAt) Created By@(!string.IsNullOrEmpty(_model.CreatedBy) ? _model.CreatedBy : "System") Last Updated At@DateTimeExtensions.ToString(_model.UpdatedAt) Last Updated By@(!string.IsNullOrEmpty(_model.UpdatedBy) ? _model.UpdatedBy : "System") @(ReadOnly ? "Back to List" : "Cancel") @if (!ReadOnly) { @if (_processing) { Updating... } else { Save Changes } } @code { [Parameter] public UpdatePatientGroupRequest Data { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private UpdatePatientGroupValidator _validator = new(); private UpdatePatientGroupRequest _model = new(); private bool _processing = false; protected override void OnInitialized() { _model = Data; } private async Task Submit() { if (ReadOnly) return; await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await PatientGroupService.UpdatePatientGroupAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Patient group updated successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }