@using Indotalent.Features.Thirdparty.Patient.Cqrs @using MudBlazor @inject PatientService PatientService @inject ISnackbar Snackbar Contact Name Title Phone Number Email Address Description Cancel @if (_processing) { Processing... } else { Add Contact } @code { [CascadingParameter] IMudDialogInstance MudDialog { get; set; } = default!; [Parameter] public string PatientId { get; set; } = string.Empty; private MudForm _form = default!; private CreatePatientContactRequest _model = new(); private bool _processing = false; private void Cancel() => MudDialog.Cancel(); private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; _model.PatientId = PatientId; try { var response = await PatientService.CreatePatientContactAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Contact added successfully", Severity.Success); MudDialog.Close(DialogResult.Ok(true)); } } finally { _processing = false; } } }