From a0c1452a84e86337456b65570684997ddb171c00 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Mon, 17 Nov 2025 00:17:23 +0330 Subject: [PATCH] Add OtpDialogService for mobile-friendly OTP authentication dialog --- .../Utilities/َOtpDialogService.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/FrontOffice.Main/Utilities/َOtpDialogService.cs diff --git a/src/FrontOffice.Main/Utilities/َOtpDialogService.cs b/src/FrontOffice.Main/Utilities/َOtpDialogService.cs new file mode 100644 index 0000000..eb9f458 --- /dev/null +++ b/src/FrontOffice.Main/Utilities/َOtpDialogService.cs @@ -0,0 +1,37 @@ +using FrontOffice.Main.Shared; +using MudBlazor; + +namespace FrontOffice.Main.Utilities; + +public class OtpDialogService + +{ + private readonly IDialogService _dialogService; + private readonly IDeviceDetector _deviceDetector; + private readonly DialogOptions _normalWidth = new() { MaxWidth = MaxWidth.ExtraSmall, FullWidth = true }; + + public OtpDialogService(IDialogService dialogService, IDeviceDetector deviceDetector) + { + ArgumentNullException.ThrowIfNull(dialogService); + ArgumentNullException.ThrowIfNull(deviceDetector); + _dialogService = dialogService!; + _deviceDetector = deviceDetector!; + } + + public async Task ShowAuthDialogAsync() + { + // Pick dialog size based on device type + var options = _deviceDetector.IsMobile() + ? new DialogOptions() { FullScreen = true} + : _normalWidth; + + var dialog = await _dialogService.ShowAsync("تأیید قرارداد", options); + var result = await dialog.Result; + + if (!result.Canceled) + { + // User logged in successfully + // You can add additional logic here if needed + } + } +} \ No newline at end of file