@page "/Login"
@using Common.Enums
@using Common.Models.Identity
@using HushianWebApp.Components
@using HushianWebApp.Service
@layout BeforeLayout
@inject AuthService auth;
@inject NavigationManager navigationManager;
هوشیان / ورود بخش شرکت ها
@code {
[Inject] protected ToastService ToastService { get; set; } = default!;
private ConfirmDialog dialog = default!;
private Modal modal = default!;
public string username { get; set; }
public string Password { get; set; }
public bool Loading { get; set; }
}
@functions {
async Task onClick()
{
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(Password)) return;
Loading = true;
var msg = await auth.login(new AuthRequest(username, Password));
if (msg == "PhoneNumberNotConfirmed")
{
var confirmation = await dialog.ShowAsync(
title: "احراز کاربری",
message1: "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید",
message2: "انجام بدیم؟");
if (!confirmation)
{
Loading = false;
return;
}
await verification();
}
else if (msg == "ok")
{
navigationManager.NavigateTo("/");
}
Loading = false;
}
async Task verification()
{
var parameters = new Dictionary();
parameters.Add("type", VerificationCodeType.PhoneNumberConfirmed);
parameters.Add("sendValue", username);
parameters.Add("ID", 0);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBackVer));
parameters.Add("Title", "کاربری/ موبایل شما فعال نشده برای ورود باید احراز کنید");
await modal.ShowAsync(title: "احراز", parameters: parameters);
}
async Task CallBackVer(VerificationCodeType type)
{
await modal.HideAsync();
}
}