Files
Hushian/Presentation/HushianWebApp/Components/EditUserYourselfComponent.razor

65 lines
2.1 KiB
Plaintext
Raw Permalink Normal View History

2025-07-12 21:33:44 +03:30
@using Common.Dtos.Exper
@using Common.Validation
2025-07-11 20:37:28 +03:30
@using HushianWebApp.Service
@using HushianWebApp.Services
@inject UserService userService;
@inject ILocalStorageService localStorageService;
<div class="row" style="height: fit-content; padding: 1rem;">
<div class="col-md-12">
<input dir="ltr" style="text-align:center;margin-bottom:10px" @bind-value="@model.FullName" type="text" class="form-control" placeholder="نام کامل" />
</div>
2025-07-12 21:33:44 +03:30
2025-07-11 20:37:28 +03:30
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
2025-07-12 21:33:44 +03:30
2025-07-11 20:37:28 +03:30
</div>
@code {
2025-07-12 21:33:44 +03:30
2025-07-11 20:37:28 +03:30
bool isAuthorizedCompanyUser = false;
2025-07-12 21:33:44 +03:30
[Parameter] public EventCallback<Update_ExperDto> OnMultipleOfThree { get; set; }
public string Role { get; set; }
2025-07-11 20:37:28 +03:30
public bool loading { get; set; } = false;
[Inject] protected ToastService ToastService { get; set; } = default!;
2025-07-12 21:33:44 +03:30
public Update_ExperDto model { get; set; } = new();
2025-07-11 20:37:28 +03:30
protected override async Task OnInitializedAsync()
{
2025-07-26 11:47:32 +03:30
var user = await userService.GetCurrentExper();
2025-07-11 20:37:28 +03:30
if (user!=null)
{
model.FullName = user.FullName;
2025-07-26 11:47:32 +03:30
Role = await localStorageService.GetItem<string>("C/Role");
2025-07-12 21:33:44 +03:30
isAuthorizedCompanyUser = Role=="Exper" && await userService.CheckAvailableExperInCompany();
2025-07-11 20:37:28 +03:30
}
else
{
ToastService.Notify(new ToastMessage(ToastType.Danger,"خطا در فراخوانی اطلاعات کاربر"));
}
await base.OnInitializedAsync();
}
2025-07-12 21:33:44 +03:30
2025-07-11 20:37:28 +03:30
async Task NewItem()
{
if (!string.IsNullOrEmpty(model.FullName))
{
2025-07-12 21:33:44 +03:30
if (!model.FullName.IsOnlyPersianLetters())
{
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را به صورت فارسی مشخص کنید"));
return;
}
2025-07-11 20:37:28 +03:30
loading = true;
if (await userService.EditUserYourself(model))
{
loading = false;
await OnMultipleOfThree.InvokeAsync(model);
}
loading = false;
}
}
}