130 lines
4.7 KiB
Plaintext
130 lines
4.7 KiB
Plaintext
|
|
@using Common.Dtos.Verification
|
|
@using Common.Enums
|
|
@using HushianWebApp.Service
|
|
@inject VerificationService verificationService;
|
|
@inject NavigationManager navigation;
|
|
|
|
<div class="header-form">
|
|
<img src="/before/assets/images/Hushian-logo.svg" width="133" alt="Hushian" class="lg:hidden mb-3">
|
|
|
|
<span>@Title</span>
|
|
</div>
|
|
<p></p>
|
|
@if (type == VerificationCodeType.ForgetPassword)
|
|
{
|
|
<div style="display: flex; justify-content: space-between">
|
|
<TextInput @bind-value=code type="text" name="code" style="text-align:center;margin-left: 10px;" placeholder="کد ارسال شده" required="required" />
|
|
|
|
</div>
|
|
|
|
<div style="display: flex; justify-content: space-between">
|
|
<TextInput @bind-value=Value type="password" name="Value" style="text-align:center;margin-top: 10px;;margin-left: 10px" placeholder="کلمه عبور جدید" required="required" />
|
|
<TextInput @bind-value=ReValue type="password" name="ReValue" style="text-align:center;margin-top: 10px;;margin-left: 10px" placeholder="تکرار کلمه عبور جدید" required="required" />
|
|
|
|
<Button Loading=loading LoadingText="ارسال درخواست" @onclick=onClick Color="ButtonColor.Success" style="margin-top: 10px;;margin-left: 10px"> احراز </Button>
|
|
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<div style="display: flex; justify-content: space-between">
|
|
<TextInput @bind-value=code type="text" name="code" style="text-align:center;margin-left: 10px;" placeholder="کد ارسال شده" required="required" />
|
|
|
|
<Button Loading=loading LoadingText="ارسال درخواست" @onclick=onClick Color="ButtonColor.Success"> احراز </Button>
|
|
|
|
</div>
|
|
}
|
|
<div style="display: flex; justify-content: space-between">
|
|
|
|
<Button Disabled=Disabledresendmsg @onclick=onClickresend Color="ButtonColor.Link" style="font-size: small;font-weight: normal;text-decoration: none;"> @resendmsg </Button>
|
|
</div>
|
|
|
|
|
|
|
|
@code {
|
|
[Parameter]
|
|
// PhoneNumberConfirmed
|
|
public VerificationCodeType type { get; set; }
|
|
[Parameter]
|
|
public string sendValue { get; set; }
|
|
[Parameter]
|
|
public int? ID { get; set; }
|
|
public string? code { get; set; }
|
|
[Parameter] public string? Title { get; set; }
|
|
[Inject] protected ToastService ToastService { get; set; } = default!;
|
|
[Parameter] public EventCallback<VerificationCodeType> OnMultipleOfThree { get; set; }
|
|
public string? Value { get; set; }
|
|
public string? ReValue { get; set; }
|
|
bool loading = false;
|
|
string resendmsg = "ارسال مجدد";
|
|
bool Disabledresendmsg = false;
|
|
}
|
|
@functions {
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
resendmsg = "در حال ارسال کد احراز ...";
|
|
Disabledresendmsg = true;
|
|
if (ID == 0)
|
|
ID = await verificationService.FromUserName(sendValue, type);
|
|
ToastService.Notify(new(ToastType.Info, $"کد احراز به کاربری '{sendValue}' ارسال شد"));
|
|
|
|
resendmsg = "ارسال مجدد";
|
|
Disabledresendmsg = false;
|
|
|
|
await base.OnParametersSetAsync();
|
|
}
|
|
async Task onClickresend()
|
|
{
|
|
resendmsg = "در حال ارسال مجدد کد احراز ...";
|
|
Disabledresendmsg = true;
|
|
if (ID == 0)
|
|
ID = await verificationService.FromUserName(sendValue, type);
|
|
else
|
|
{
|
|
await verificationService.ReSendCode(ID.Value);
|
|
}
|
|
|
|
ToastService.Notify(new(ToastType.Info, $"کد احراز به کاربری '{sendValue}' ارسال شد"));
|
|
|
|
resendmsg = "ارسال مجدد";
|
|
Disabledresendmsg = false;
|
|
}
|
|
async Task onClick()
|
|
{
|
|
if (string.IsNullOrEmpty(code))
|
|
{
|
|
ToastService.Notify(new(ToastType.Warning, $"کد ارسالی را وارد کنید"));
|
|
return;
|
|
}
|
|
|
|
if (type == VerificationCodeType.ForgetPassword)
|
|
{
|
|
if (string.IsNullOrEmpty(Value) || string.IsNullOrEmpty(ReValue))
|
|
{
|
|
ToastService.Notify(new(ToastType.Warning, $"کلمه عبور جدید را مشخص کنید"));
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (Value != ReValue)
|
|
{ ToastService.Notify(new(ToastType.Warning, $"کلمه عبور جدید و تکرار متفاوت هستند"));
|
|
return;}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
loading = true;
|
|
if (await verificationService.ConfirmedCode(new ConfirmedCodeDto()
|
|
{ code = code, codeType = type, Id = ID.Value, value = Value }))
|
|
{
|
|
ToastService.Notify(new(ToastType.Success, $"احراز با موفقیت انجام شد برای ادامه ورود کنید"));
|
|
await OnMultipleOfThree.InvokeAsync(type);
|
|
|
|
}
|
|
loading = false;
|
|
}
|
|
}
|
|
|