This commit is contained in:
mmrbnjd
2024-04-30 16:40:05 +03:30
parent 319270d567
commit 827aa36860
8 changed files with 258 additions and 8 deletions

View File

@@ -40,19 +40,19 @@
</NavLink>
</li>
<li class="menu-item @cssActionItem[5]" @onclick="() => onClickcssActionItem(5)">
<NavLink href="#" target="_blank" class="menu-link">
<NavLink href="#" class="menu-link">
<i class="menu-icon tf-icons bx bx-support"></i>
<div>پشتیبانی</div>
</NavLink>
</li>
<li class="menu-item @cssActionItem[6]" @onclick="() => onClickcssActionItem(6)">
<NavLink href="#" target="_blank" class="menu-link">
<NavLink href="#" class="menu-link">
<i class="menu-icon tf-icons bx bx-copy"></i>
<div >سفارشات</div>
</NavLink>
</li>
<li class="menu-item @cssActionItem[7]" @onclick="() => onClickcssActionItem(7)">
<NavLink href="#" target="_blank" class="menu-link">
<NavLink href="Setting" class="menu-link">
<i class="menu-icon tf-icons bx bx-file"></i>
<div>تنظیمات</div>
</NavLink>

View File

@@ -0,0 +1,134 @@
@page "/Setting"
@* @page "/Profile/{from}" *@
@using Front.Services
@using Shared.DTOs
@layout PanelLayout
@inject UserAuthenticationDTO userinfo
@inject HttpClientController _hc
@inject ILocalStorageService Storage;
<div class="container-xxl flex-grow-1 container-p-y">
<h4 class="fw-bold py-3 mb-4">
<span class="text-muted fw-light">متفرقه /</span> تنظیمات
</h4>
<div class="row">
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
</div>
<div class="row">
<div class="col-md-12">
<div class="card mb-4">
<h5 class="card-header">مالیات</h5>
<div class="card-body">
<EditForm Model="InfoModel" OnSubmit="Submit" FormName="TaxPayer">
<div class="row">
<div class="mb-3 col-md-6">
<label for="defaultFormControlInput" class="form-label">کد اقتصادی</label>
<InputText @bind-Value="@InfoModel.EconomicCode" style="text-align:center;" class="form-control" type="text" id="EconomicCode" />
</div>
<div class="mb-3 col-md-6">
<label for="defaultFormControlInput" class="form-label">حافظه مالیاتی</label>
<InputText style="text-align:center;" @bind-Value="@InfoModel.UniqeMemory" class="form-control" type="text" id="UniqeMemory" />
</div>
<div class="mb-3 col-md-6">
<label for="defaultFormControlInput" class="form-label">کلید خصوصی</label>
<InputText @bind-Value="@InfoModel.PrivateKey" style="text-align:center;" class="form-control" type="text" id="PrivateKey" />
</div>
<div class="mb-3 col-md-6">
<label for="defaultFormControlInput" class="form-label">کد شعبه</label>
<InputText @bind-Value="@InfoModel.BranchID" style="text-align:center;" class="form-control" type="text" id="BaranchID" />
</div>
</div>
<div class="mt-2">
<button type="submit" class="btn btn-primary">ارسال</button>
</div>
</EditForm>
</div>
</div>
</div>
</div>
</div>
@code {
[SupplyParameterFromForm]
public TaxPayerInfoDto? InfoModel { get; set; }
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
protected override async Task OnInitializedAsync()
{
InfoModel ??= new();
var request = await _hc.Get($"Company/TaxPayerInfo");
if (request.IsSuccessStatusCode)
{
InfoModel = await request.Content.ReadFromJsonAsync<TaxPayerInfoDto>();
}
else
_hc._nav.NavigateTo("Panel");
await base.OnInitializedAsync();
}
}
@functions{
private void ShowDangerAlert(string msg)
{
Hidealert = false;
alertColor = AlertColor.Danger;
alertIconName = IconName.ExclamationTriangleFill;
alertMessage = msg;
}
private void ShowSuccessAlert(string msg)
{
Hidealert = false;
alertColor = AlertColor.Success;
alertIconName = IconName.CheckCircleFill;
alertMessage = msg;
}
private async Task Submit()
{
var request = await _hc.Put($"Company/ChangeTaxPayerInfo", InfoModel);
if (request.IsSuccessStatusCode)
{
if (await request.Content.ReadFromJsonAsync<bool>())
{
ShowSuccessAlert("تغییر نام با موفقیت انجام شد");
}
else
{
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
}
else
{
var errors = await request.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(errors[0]);
}
}
}

View File

@@ -14,7 +14,23 @@ builder.Services.AddBlazorBootstrap();
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
builder.Services.AddScoped<localService>();
builder.Services.AddScoped<HttpClientController>();
builder.Services.AddScoped(sp => new UserAuthenticationDTO());
builder.Services.AddScoped(sp => new UserAuthenticationDTO()
{
Company = new CompanyAuthenticationDTO()
{
ID = 0,
IsAdmin = false,
Logo = "",
Name = ""
}
,
FullName = "",
Photo="",
Token="",
UserName = "",
enterDate =new DateTime(),
exitDate = new DateTime(),
}) ;
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });

View File

@@ -26,5 +26,12 @@ namespace Front.Services
_nav.NavigateTo("/Sign-in/unon");
return request;
}
public async Task<HttpResponseMessage> Put<T>(string route, T mode)
{
var request = await _hc.PutAsJsonAsync(route, mode);
if (request.StatusCode == System.Net.HttpStatusCode.Unauthorized)
_nav.NavigateTo("/Sign-in/unon");
return request;
}
}
}