Files
Hushian/Presentation/HushianWebApp/Pages/Manage/Settings.razor

168 lines
6.1 KiB
Plaintext
Raw Normal View History

2025-07-11 20:37:28 +03:30
@page "/Settings"
2025-07-12 21:33:44 +03:30
@using Common.Dtos.Company
2025-07-11 20:37:28 +03:30
@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">
2025-07-26 11:47:32 +03:30
@* <div class="row row-fullheight"> *@
<div class="row">
2025-07-11 20:37:28 +03:30
<!-- تغییر کلمه عبور -->
<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">
2025-07-12 21:33:44 +03:30
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.FullName" type="text" placeholder="نام شرکت" />
</div>
<div class="col-md-12" style="margin-top:15px">
<input dir="ltr" class="form-control text-center mb-2" @bind-value="@dto.FullNameManager" type="text" placeholder="نام مدیر" />
2025-07-11 20:37:28 +03:30
</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>
2025-07-26 11:47:32 +03:30
2025-07-11 20:37:28 +03:30
<div class="col-md-12 d-flex align-items-center mb-2">
<InputFile type="file" OnChange="OnFileChange" accept=".png" />
2025-07-12 21:33:44 +03:30
@if (dto.logo != null && dto.logo.Length > 0)
2025-07-11 20:37:28 +03:30
{
<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"
2025-07-12 21:33:44 +03:30
@onclick="updateItem">
2025-07-11 20:37:28 +03:30
ویرایش
</Button>
</div>
</div>
</div>
}
2025-07-26 11:47:32 +03:30
@* <!-- پایین چپ -->
2025-07-11 20:37:28 +03:30
<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>
2025-07-26 11:47:32 +03:30
</div> *@
2025-07-11 20:37:28 +03:30
</div>
</div>
@code {
2025-07-26 11:47:32 +03:30
[Inject] protected ToastService ToastService { get; set; } = default!;
2025-07-11 20:37:28 +03:30
2025-07-26 11:47:32 +03:30
bool ALLOWcompanyinfo = false;
2025-07-11 20:37:28 +03:30
public bool loading { get; set; } = false;
2025-07-12 21:33:44 +03:30
public ReadANDUpdate_CompanyDto dto { get; set; }
2025-07-11 20:37:28 +03:30
= new();
2025-07-12 21:33:44 +03:30
int CompanyID = 0;
2025-07-11 20:37:28 +03:30
protected override async Task OnInitializedAsync()
{
2025-07-26 11:47:32 +03:30
if (await localStorageService.GetItem<string>("C/Role") == "User")
2025-07-11 20:37:28 +03:30
navigationManager.NavigateTo("/NotFound");
2025-07-26 11:47:32 +03:30
ALLOWcompanyinfo = await localStorageService.GetItem<string>("C/Role") == "Company";
2025-07-12 21:33:44 +03:30
CompanyID= await localStorageService.GetItem<int>("C/CompanyId");
2025-07-11 20:37:28 +03:30
2025-07-12 21:33:44 +03:30
dto = await companyService.GetCompany(CompanyID);
2025-07-11 20:37:28 +03:30
await base.OnInitializedAsync();
}
private async Task OnFileChange(InputFileChangeEventArgs e)
{
var file = e.File;
using (var memoryStream = new MemoryStream())
{
await file.OpenReadStream().CopyToAsync(memoryStream);
2025-07-12 21:33:44 +03:30
dto.logo = memoryStream.ToArray();
2025-07-11 20:37:28 +03:30
}
}
private string GetImageSource()
{
2025-07-12 21:33:44 +03:30
if (dto.logo != null)
2025-07-11 20:37:28 +03:30
{
2025-07-12 21:33:44 +03:30
return $"data:image/jpeg;base64,{Convert.ToBase64String(dto.logo)}";
2025-07-11 20:37:28 +03:30
}
return string.Empty;
}
async Task updateItem()
{
if (await companyService.UpdateCompany(dto))
ToastService.Notify(new ToastMessage(ToastType.Success, "تغییر اطلاعات شرکت با موفقیت انجام شد"));
}
}