using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using CurrieTechnologies.Razor.SweetAlert2; namespace BlazorPages.Tools { public class SwalUtils : ISwalUtils { private readonly SweetAlertService _service; public SwalUtils(SweetAlertService service) { _service = service; } public async Task ShowToast(string message) { return await _service.FireAsync( new SweetAlertOptions { Toast = true, Text = message, Timer = 5000, ConfirmButtonText = "خُب" }); } public async Task ShowSwal(string title, string message, SweetAlertIcon icon) { if (icon == SweetAlertIcon.Question) return await _service.FireAsync(new SweetAlertOptions { ShowConfirmButton = true, CancelButtonColor = "Red", ShowCloseButton = false, ShowCancelButton = true, Html = message, Icon = icon, Title = title, CancelButtonText = "انصراف", ConfirmButtonText = "تائید" }); return await _service.FireAsync(new SweetAlertOptions { ShowConfirmButton = false, ShowCloseButton = false, ShowCancelButton = true, Html = message, Icon = icon, Title = title, CancelButtonText = "خًب" }); } } }