166 lines
6.0 KiB
Plaintext
166 lines
6.0 KiB
Plaintext
![]() |
@page "/Settings"
|
||
|
@using Hushian.Application.Dtos.Company
|
||
|
@using HushianWebApp.Components
|
||
|
@using HushianWebApp.Service
|
||
|
@using HushianWebApp.Services
|
||
|
@inject ILocalStorageService localStorageService;
|
||
|
@inject NavigationManager navigationManager;
|
||
|
@inject CompanyService companyService;
|
||
|
<style>
|
||
|
.section-box {
|
||
|
background-color: #f8f9fa;
|
||
|
border-radius: 1rem;
|
||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||
|
padding: 1.5rem;
|
||
|
margin-bottom: 1rem;
|
||
|
height: 100%;
|
||
|
}
|
||
|
|
||
|
.section-title {
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
font-size: 1.25rem;
|
||
|
font-weight: 600;
|
||
|
color: #343a40;
|
||
|
margin-bottom: 1rem;
|
||
|
border-right: 4px solid #ffc107;
|
||
|
padding-right: 0.75rem;
|
||
|
}
|
||
|
|
||
|
.section-title i {
|
||
|
margin-left: 0.5rem;
|
||
|
color: #ffc107;
|
||
|
}
|
||
|
|
||
|
.row-fullheight {
|
||
|
min-height: 100vh;
|
||
|
display: flex;
|
||
|
flex-wrap: wrap;
|
||
|
}
|
||
|
</style>
|
||
|
|
||
|
<div class="container-fluid">
|
||
|
<div class="row row-fullheight">
|
||
|
|
||
|
<!-- تغییر کلمه عبور -->
|
||
|
<div class="col-md-6 d-flex flex-column" style="height: fit-content;">
|
||
|
<div class="section-box w-100">
|
||
|
<div class="section-title">
|
||
|
<i class="bi bi-layout-text-window-reverse"></i> تغییر کلمه عبور
|
||
|
</div>
|
||
|
<ChangePassWordComponent/>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
@if (ALLOWcompanyinfo)
|
||
|
{
|
||
|
<!-- اطلاعات شرکت -->
|
||
|
<div class="col-md-6 d-flex flex-column" style="height: fit-content;">
|
||
|
<div class="section-box w-100">
|
||
|
<div class="section-title">
|
||
|
<i class="bi bi-gear-fill"></i> اطلاعات شرکت
|
||
|
</div>
|
||
|
|
||
|
<div class="form-group row mb-3" style="padding-left: 10em;">
|
||
|
<div class="col-md-6">
|
||
|
<Switch @bind-Value="dto.Available" Label="در دسترس" />
|
||
|
</div>
|
||
|
<div class="col-md-6">
|
||
|
<Switch @bind-Value="dto.allowBot" Label="پاسخگوی هوشمند" />
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="col-md-12" style="margin-top:15px">
|
||
|
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Fullname" type="text" placeholder="نام کامل" />
|
||
|
</div>
|
||
|
<div class="col-md-12">
|
||
|
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Email" type="text" placeholder="پست الکترونیک" />
|
||
|
</div>
|
||
|
<div class="col-md-12">
|
||
|
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.WebSite" type="text" placeholder="وب سایت" />
|
||
|
</div>
|
||
|
<div class="col-md-12">
|
||
|
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Phone" type="text" placeholder="تلفن" />
|
||
|
</div>
|
||
|
<div class="col-md-12">
|
||
|
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.Info" type="text" placeholder="توضیحات" />
|
||
|
</div>
|
||
|
<div class="col-md-12 d-flex align-items-center mb-2">
|
||
|
<InputFile type="file" OnChange="OnFileChange" accept=".png" />
|
||
|
@if (dto.img != null && dto.img.Length > 0)
|
||
|
{
|
||
|
<Image src="@GetImageSource()" class="rounded mx-2" height="25" width="25" alt="Uploaded Image" />
|
||
|
}
|
||
|
</div>
|
||
|
<div class="d-grid gap-2">
|
||
|
<Button Loading=loading LoadingText="در حال ذخیره اطلاعات..." Color="ButtonColor.Warning"
|
||
|
@onclick="updateItem">
|
||
|
ویرایش
|
||
|
</Button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
}
|
||
|
|
||
|
|
||
|
<!-- پایین چپ -->
|
||
|
<div class="col-md-6 d-flex flex-column">
|
||
|
<div class="section-box w-100">
|
||
|
<div class="section-title">
|
||
|
<i class="bi bi-graph-up"></i> بخش پایین چپ
|
||
|
</div>
|
||
|
<!-- محتوای دلخواه -->
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<!-- پایین راست -->
|
||
|
<div class="col-md-6 d-flex flex-column">
|
||
|
<div class="section-box w-100">
|
||
|
<div class="section-title">
|
||
|
<i class="bi bi-chat-dots-fill"></i> بخش پایین راست
|
||
|
</div>
|
||
|
<!-- محتوای دلخواه -->
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
@code {
|
||
|
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||
|
|
||
|
bool ALLOWcompanyinfo = true;
|
||
|
public bool loading { get; set; } = false;
|
||
|
public CompanyDto dto { get; set; }
|
||
|
= new();
|
||
|
protected override async Task OnInitializedAsync()
|
||
|
{
|
||
|
if (!(await localStorageService.GetItem<List<string>>("Role")).Any(a => a == "HushianManagerCompany"))
|
||
|
navigationManager.NavigateTo("/NotFound");
|
||
|
|
||
|
dto=await companyService.GetCompany();
|
||
|
await base.OnInitializedAsync();
|
||
|
}
|
||
|
private async Task OnFileChange(InputFileChangeEventArgs e)
|
||
|
{
|
||
|
var file = e.File;
|
||
|
using (var memoryStream = new MemoryStream())
|
||
|
{
|
||
|
await file.OpenReadStream().CopyToAsync(memoryStream);
|
||
|
dto.img = memoryStream.ToArray();
|
||
|
}
|
||
|
}
|
||
|
private string GetImageSource()
|
||
|
{
|
||
|
if (dto.img != null)
|
||
|
{
|
||
|
return $"data:image/jpeg;base64,{Convert.ToBase64String(dto.img)}";
|
||
|
}
|
||
|
return string.Empty;
|
||
|
}
|
||
|
async Task updateItem()
|
||
|
{
|
||
|
if (await companyService.UpdateCompany(dto))
|
||
|
ToastService.Notify(new ToastMessage(ToastType.Success, "تغییر اطلاعات شرکت با موفقیت انجام شد"));
|
||
|
}
|
||
|
}
|