This commit is contained in:
mmrbnjd
2024-04-29 18:15:46 +03:30
parent 7b8127dc72
commit 319270d567
20 changed files with 356 additions and 96 deletions

View File

@@ -1,4 +1,5 @@
@page "/Profile"
@page "/Profile/{from}"
@using Front.Services
@using Shared.DTOs
@layout PanelLayout
@@ -53,19 +54,19 @@
<div class="mb-3 row">
<label for="defaultFormControlInput" class="form-label">کلمه عبور فعلی</label>
<div class="col-md-10">
<InputText @bind-Value="@changepassModel.oldPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input"/>
<InputText @bind-Value="@changepassModel.oldPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input1"/>
</div>
</div>
<div class="mb-3 row">
<label for="defaultFormControlInput" class="form-label">کلمه عبور جدید</label>
<div class="col-md-10">
<InputText style="text-align:center;" @bind-Value="@changepassModel.newPass" class="form-control" type="password" id="html5-password-input" />
<InputText style="text-align:center;" @bind-Value="@changepassModel.newPass" class="form-control" type="password" id="html5-password-input2" />
</div>
</div>
<div class="mb-3 row">
<label for="defaultFormControlInput" class="form-label">تکرار کلمه عبور جدید</label>
<div class="col-md-10">
<InputText @bind-Value="@changepassModel.renewPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input" />
<InputText @bind-Value="@changepassModel.renewPass" style="text-align:center;" class="form-control" type="password" id="html5-password-input3" />
</div>
</div>
<button type="submit" class="btn btn-primary">ارسال</button>
@@ -78,16 +79,16 @@
<div class="card mb-4">
<h5 class="card-header">تغییر نام کاربری/ موبایل</h5>
<div class="card-body">
<form>
<EditForm Model="newUsername" OnSubmit="changeUserNameSubmit" FormName="changeUsername">
<div class="mb-3 row">
<label for="defaultFormControlInput" class="form-label">موبایل جدید</label>
<div class="input-group input-group-merge">
<input type="text" style="text-align:left;" id="basic-icon-default-phone" class="form-control phone-mask" placeholder="0000 000 0911" aria-label="0000 000 0911" value="@userinfo.UserName" aria-describedby="basic-icon-default-phone2">
<InputText @bind-Value="@newUsername" type="text" style="text-align:left;" id="basic-icon-default-phone" class="form-control phone-mask" placeholder="0000 000 0911" aria-label="0000 000 0911" aria-describedby="basic-icon-default-phone2"/>
<span id="basic-icon-default-phone2" class="input-group-text"><i class="bx bx-phone"></i></span>
</div>
</div>
<button type="submit" class="btn btn-primary">ارسال</button>
</form>
</EditForm>
</div>
</div>
@@ -98,16 +99,16 @@
<div class="card mb-4">
<h5 class="card-header">تغییر نام</h5>
<div class="card-body">
<form>
<EditForm Model="newname" OnSubmit="changeNameSubmit" FormName="changename">
<div class="mb-3 row">
<label for="defaultFormControlInput" class="form-label">نام جدید</label>
<div class="input-group input-group-merge">
<span id="basic-icon-default-company2" class="input-group-text"><i class="bx bx-buildings"></i></span>
<input style="text-align:right;" type="text" id="basic-icon-default-company" value="@userinfo.Company.Name" class="form-control" placeholder="@userinfo.Company.Name" aria-label="@userinfo.Company.Name" aria-describedby="basic-icon-default-company2">
<InputText @bind-Value="@newname" style="text-align:right;" type="text" id="basic-icon-default-company" class="form-control" placeholder="@userinfo.Company.Name" aria-label="@userinfo.Company.Name" aria-describedby="basic-icon-default-company2"/>
</div>
</div>
<button type="submit" class="btn btn-primary">ارسال</button>
</form>
</EditForm>
</div>
</div>
</div>
@@ -118,17 +119,37 @@
@code {
[Parameter]
public string from { get; set; } = "";
public string _src { get; set; }
private long maxFileSize = 1024 * 15;
[SupplyParameterFromForm]
public ChangePasswordDto changepassModel { get; set; }
[SupplyParameterFromForm]
public string newUsername { get; set; }
[SupplyParameterFromForm]
public string newname { get; set; }
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
protected override async Task OnParametersSetAsync()
{
if (from == "Verification")
{
ShowSuccessAlert("تغییر کاربری با موفقیت انجام شد");
}
protected override void OnInitialized() => changepassModel ??= new();
await base.OnParametersSetAsync();
}
protected override void OnInitialized()
{
newname ??= userinfo.Company.Name;
newUsername ??= userinfo.UserName;
changepassModel ??= new();
}
}
@functions{
private void ShowDangerAlert(string msg)
@@ -163,6 +184,54 @@
ShowDangerAlert(errors[0]);
}
}
private async Task changeUserNameSubmit()
{
if (newUsername != userinfo.UserName)
{
var request = await _hc.Get($"User/ChangeUserName/{newUsername}");
if (request.IsSuccessStatusCode)
{
var VerificationID = await request.Content.ReadFromJsonAsync<int>();
_hc._nav.NavigateTo($"Verification/{VerificationID}");
}
else
{
var errors = await request.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(errors[0]);
}
}
}
private async Task changeNameSubmit()
{
if (newname != userinfo.Company.Name)
{
var request = await _hc.Get($"Company/ChangeName/{newname}");
if (request.IsSuccessStatusCode)
{
if (await request.Content.ReadFromJsonAsync<bool>())
{
userinfo.FullName= userinfo.Company.Name = newname;
ShowSuccessAlert("تغییر نام با موفقیت انجام شد");
}
else
{
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
}
else
{
var errors = await request.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(errors[0]);
}
}
}
private async Task changePic(InputFileChangeEventArgs e){
if (e.GetMultipleFiles()[0].Size <= maxFileSize)
{
@@ -188,7 +257,7 @@
}
else
{
ShowDangerAlert ( "خطایی در اجرای عملیات رخ داده");
ShowDangerAlert( "خطایی در اجرای عملیات رخ داده");
}
}
}
@@ -197,4 +266,5 @@
ShowDangerAlert ( "حجم فایل بیشتر از حد مجاز می باشد");
}
}
}