Add device detection and PDF generation features; refactor AuthDialog and update print utilities

This commit is contained in:
masoodafar-web
2025-11-14 13:12:31 +03:30
parent e86cb7aa47
commit 230ba41113
12 changed files with 397 additions and 54 deletions

View File

@@ -8,7 +8,7 @@
}
else
{
<MudDialog >
<MudDialog>
<TitleContent>
<MudText Typo="Typo.h4" Align="Align.Center">@GetDialogTitle()</MudText>
</TitleContent>
@@ -20,7 +20,8 @@ else
{
<MudButton Variant="Variant.Text"
OnClick="Cancel"
Disabled="_isBusy">لغو</MudButton>
Disabled="_isBusy">لغو
</MudButton>
}
@if (_currentStep == AuthStep.Phone)
{
@@ -47,6 +48,7 @@ else
}
@code {
private RenderFragment PhoneOrVerifyContent() => __builder =>
{
if (_currentStep == AuthStep.Phone)
@@ -70,37 +72,51 @@ else
Required="true"
RequiredError="وارد کردن شماره موبایل الزامی است."
HelperText="مثال: 09121234567"
Class="mb-2" />
Class="mb-2"/>
@* @if (EnableCaptcha) *@
@* { *@
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2" Class="mt-2 mb-2">
<MudPaper Elevation="1" Class="captcha-box d-flex align-center justify-center" Style="min-width:100px;min-height:48px;">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1" Class="mt-2 mb-2">
<MudItem xs="7" md="12">
<MudTextField xs="4" Label="کد کپچا" Placeholder="کد نمایش داده شده" Immediate="true"
Variant="Variant.Outlined" @bind-Value="_captchaInput" Required="true"
RequiredError="لطفاً کد کپچا را وارد کنید."/>
</MudItem>
<MudItem xs="4" >
<MudPaper Elevation="1" Class="captcha-box d-flex align-center justify-center"
Style="min-width:100px;min-height:48px;">
<MudText Typo="Typo.h5">@_captchaCode</MudText>
</MudPaper>
<MudButton Variant="Variant.Text" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Refresh" Disabled="_isBusy" OnClick="GenerateCaptcha">
تازه‌سازی کد
</MudItem>
<MudItem xs="1" >
<MudButton Variant="Variant.Text" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Refresh" Disabled="_isBusy"
OnClick="GenerateCaptcha">
</MudButton>
</MudStack>
<MudTextField Label="کد کپچا" Placeholder="کد نمایش داده شده" Immediate="true"
Variant="Variant.Outlined" @bind-Value="_captchaInput" Required="true"
RequiredError="لطفاً کد کپچا را وارد کنید." />
@* } *@
</MudItem>
<MudCheckBox T="bool"
</MudStack>
@* } *@
@* *@
<MudCheckBox T="bool" Required="true"
Label="شرایط و قوانین را می‌پذیرم"
Class="mb-1" />
RequiredError="برای ادامه باید شرایط و قوانین را بپذیرید."
Class="mb-1"/>
@if (!string.IsNullOrWhiteSpace(_errorMessage))
{
<MudAlert Severity="Severity.Error" Dense="true" Elevation="0" Class="mb-2">@_errorMessage</MudAlert>
<MudAlert Severity="Severity.Error" Dense="true" Elevation="0"
Class="mb-2">@_errorMessage</MudAlert>
}
</MudForm>
}
else if (_currentStep == AuthStep.Verify)
{
// Verify Step
<MudText Typo="Typo.body2" Class="mb-4" Align="Align.Center">رمز پویا شش رقمی ارسال ‌شده به @_phoneNumber را وارد کنید.</MudText>
<MudText Typo="Typo.body2" Class="mb-4" Align="Align.Center">رمز پویا شش رقمی ارسال ‌شده به @_phoneNumber را
وارد کنید.
</MudText>
<MudForm @ref="_verifyForm" Model="_verifyRequest" Validation="@(_verifyRequestValidator.ValidateValue)">
<MudTextField @bind-Value="_verifyRequest.Code"
@@ -114,30 +130,39 @@ else
RequiredError="وارد کردن رمز پویا الزامی است."
HelperText="کد ۶ رقمی"
Class="mb-2"
MaxLength="6" />
MaxLength="6"/>
@if (!string.IsNullOrWhiteSpace(_errorMessage))
{
<MudAlert Severity="Severity.Error" Dense="true" Elevation="0" Class="mb-2">@(_errorMessage)</MudAlert>
<MudAlert Severity="Severity.Error" Dense="true" Elevation="0"
Class="mb-2">@(_errorMessage)</MudAlert>
}
@if (!string.IsNullOrWhiteSpace(_infoMessage))
{
<MudAlert Severity="Severity.Success" Dense="true" Elevation="0" Class="mb-2">@(_infoMessage)</MudAlert>
<MudAlert Severity="Severity.Success" Dense="true" Elevation="0"
Class="mb-2">@(_infoMessage)</MudAlert>
}
<MudStack Spacing="2">
<MudButton Variant="Variant.Text" Color="Color.Secondary" Disabled="_isBusy" OnClick="ChangePhoneAsync">تغییر شماره</MudButton>
<MudButton Variant="Variant.Text" Color="Color.Secondary" Disabled="_isBusy"
OnClick="ChangePhoneAsync">تغییر شماره
</MudButton>
</MudStack>
<MudDivider Class="my-2" />
<MudDivider Class="my-2"/>
@if (_resendRemaining > 0)
{
<MudText Typo="Typo.body2" Align="Align.Center" Class="mud-text-secondary">امکان ارسال مجدد تا @_resendRemaining ثانیه دیگر</MudText>
<MudText Typo="Typo.body2" Align="Align.Center" Class="mud-text-secondary">امکان ارسال مجدد
تا @_resendRemaining ثانیه دیگر
</MudText>
}
else
{
<MudButton Variant="Variant.Text" Color="Color.Primary" Disabled="_isBusy" OnClick="ResendOtpAsync">ارسال مجدد رمز پویا</MudButton>
<MudButton Variant="Variant.Text" Color="Color.Primary" Disabled="_isBusy" OnClick="ResendOtpAsync">
ارسال مجدد رمز پویا
</MudButton>
}
</MudForm>
}
};
}