Files
TaskHybrid/salesbook.Shared/Components/SingleElements/Card/UserCard.razor
2025-06-26 10:08:21 +02:00

74 lines
2.7 KiB
Plaintext

@using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface
@inject IManageDataService ManageData
<div class="user-card-card">
<div class="user-card-left-section">
<div class="user-card-body-section">
<div class="title-section">
<MudIcon @onclick="OpenUser" Color="Color.Primary" Icon="@Icons.Material.Filled.Person" Size="Size.Large" />
<div class="user-card-right-section">
<div class="user-card-title">
<MudText Typo="Typo.body1" @onclick="OpenUser" HtmlTag="h3">@User.RagSoc</MudText>
<MudIcon @onclick="ShowCommesse" Color="Color.Info" Icon="@Icons.Material.Outlined.Info" Size="Size.Medium"/>
</div>
<div class="user-card-subtitle @(ShowSectionCommesse ? "show" : "")">
@if (ShowSectionCommesse && IsLoading)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
}
else
{
@if (!Commesse.IsNullOrEmpty())
{
<div @onclick="OpenUser" class="container-commesse">
@foreach (var commessa in Commesse!)
{
<div class="commessa">
<span>@($"{commessa.CodJcom} - {commessa.Descrizione}")</span>
</div>
}
</div>
}
else
{
<div class="commessa">
<span>Nessuna commessa presente</span>
</div>
}
}
</div>
</div>
</div>
</div>
</div>
</div>
@code {
[Parameter] public AnagClie User { get; set; } = new();
private List<JtbComt>? Commesse { get; set; }
private bool IsLoading { get; set; } = true;
private bool ShowSectionCommesse { get; set; }
private void OpenUser() =>
NavigationManager.NavigateTo($"/User/{User.CodAnag}");
private async Task ShowCommesse()
{
ShowSectionCommesse = !ShowSectionCommesse;
if (ShowSectionCommesse)
{
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag.Equals(User.CodAnag));
IsLoading = false;
StateHasChanged();
return;
}
IsLoading = true;
}
}