diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor index c83bd6e..875dc3c 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor @@ -1,5 +1,5 @@
-
+
Actors +
+
+ picture +
+
+
+
+ + @if (_person is null) + { + Loading... + } + else + { + @(_person.Name)@(Role is ActorRoleResponse actor ? $" as {actor.Name}" : string.Empty) + } + +
+
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs index 993df6f..6e060fa 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs @@ -1,14 +1,65 @@ using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Services.WebAPI.Persons; namespace WatchIt.Website.Components.MediaPage; -public partial class RoleComponent : ComponentBase +public partial class RoleComponent : ComponentBase where TRole : IRoleResponse { - #region PARAMETERS - - [Parameter] public string? AdditionalName { get; set; } + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; #endregion + + #region PARAMETERS + + [Parameter] public required TRole Role { get; set; } + + #endregion + + + + #region FIELDS + + private PersonResponse? _person; + private Picture? _picture; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data => + { + _picture = data; + StateHasChanged(); + }), + PersonsWebAPIService.GetPerson(Role.PersonId, data => + { + _person = data; + StateHasChanged(); + }) + ]); + + // END + await Task.WhenAll(endTasks); + } + } + + #endregion } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor index 604aee1..ad41b4c 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor @@ -10,15 +10,21 @@ {
} - + + + + } + @if (!_allItemsLoaded) + { +
+ +
} -
- -
} else diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs index 92d0736..a9809de 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs @@ -72,8 +72,8 @@ public partial class RoleListComponent : ComponentBase where TRol { Query.After = 0; } - Query.After += _pageSize; } + Query.After += data.Count(); _rolesFetching = false; }); }