Files
Hushian/Presentation/HushianWebApp/Components/EditUserYourselfComponent.razor
mmrbnjd c045ace959 ...
2025-07-26 11:47:32 +03:30

65 lines
2.1 KiB
Plaintext

@using Common.Dtos.Exper
@using Common.Validation
@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>
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning" @onclick="NewItem"> ویرایش </Button>
</div>
@code {
bool isAuthorizedCompanyUser = false;
[Parameter] public EventCallback<Update_ExperDto> OnMultipleOfThree { get; set; }
public string Role { get; set; }
public bool loading { get; set; } = false;
[Inject] protected ToastService ToastService { get; set; } = default!;
public Update_ExperDto model { get; set; } = new();
protected override async Task OnInitializedAsync()
{
var user = await userService.GetCurrentExper();
if (user!=null)
{
model.FullName = user.FullName;
Role = await localStorageService.GetItem<string>("C/Role");
isAuthorizedCompanyUser = Role=="Exper" && await userService.CheckAvailableExperInCompany();
}
else
{
ToastService.Notify(new ToastMessage(ToastType.Danger,"خطا در فراخوانی اطلاعات کاربر"));
}
await base.OnInitializedAsync();
}
async Task NewItem()
{
if (!string.IsNullOrEmpty(model.FullName))
{
if (!model.FullName.IsOnlyPersianLetters())
{
ToastService.Notify(new(ToastType.Danger, $"نام و نام خانوادگی را به صورت فارسی مشخص کنید"));
return;
}
loading = true;
if (await userService.EditUserYourself(model))
{
loading = false;
await OnMultipleOfThree.InvokeAsync(model);
}
loading = false;
}
}
}