@page "/commessa/{CodJcom}" @page "/commessa/{CodJcom}/{RagSoc}" @attribute [Authorize] @using AutoMapper @using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.Layout.Spinner @using salesbook.Shared.Components.SingleElements @using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Dto.Activity @using salesbook.Shared.Core.Dto.JobProgress @using salesbook.Shared.Core.Dto.PageState @using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Interface @inject JobSteps JobSteps @inject IManageDataService ManageData @inject IIntegryApiService IntegryApiService @inject IMapper Mapper @if (IsLoading) { } else {
@if (CommessaModel == null) { } else {
@if (Steps != null) {
@foreach (var step in Steps) {
@step.StepName
@if (step.Date is not null) {
@($"{step.Date.Value:D}") @(step.Status!.Progress ? "(In corso...)" : "")
}
}
}
@if (ActivityIsLoading) { } else { @if (ActivityList is { Count: > 0 }) {
} else { } }
@if (AttachedIsLoading) { } else { @if (ListAttached != null) {
} else { } }
}
} @code { [Parameter] public string CodJcom { get; set; } = ""; [Parameter] public string RagSoc { get; set; } = ""; private List? Steps { get; set; } private List ActivityList { get; set; } = []; private List? ListAttached { get; set; } private JtbComt? CommessaModel { get; set; } private bool IsLoading { get; set; } = true; private bool ActivityIsLoading { get; set; } = true; private bool AttachedIsLoading { get; set; } = true; protected override async Task OnInitializedAsync() { await LoadData(); } private async Task LoadData() { CommessaModel = (await ManageData.GetTable(x => x.CodJcom.Equals(CodJcom))).LastOrDefault(); Steps = JobSteps.Steps; _ = LoadActivity(); _ = LoadAttached(); IsLoading = false; } private async Task LoadActivity() { await Task.Run(async () => { var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodJcom = CodJcom }); ActivityList = Mapper.Map>(activities) .OrderBy(x => (x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct ).ToList(); }); ActivityIsLoading = false; StateHasChanged(); } private async Task LoadAttached() { await Task.Run(async () => { ListAttached = await IntegryApiService.RetrieveAttached(CodJcom); }); AttachedIsLoading = false; StateHasChanged(); } }