1
0
mirror of synced 2024-12-04 19:07:58 +01:00
TaikoLocalServer/TaikoWebUI/Pages/Users.razor.cs

41 lines
1.0 KiB
C#
Raw Normal View History

2024-03-16 10:46:06 +01:00
namespace TaikoWebUI.Pages;
2022-09-11 18:33:58 +02:00
public partial class Users
2022-09-11 18:33:58 +02:00
{
private UsersResponse? response = new();
private int TotalPages { get; set; } = 0;
private bool isLoading = true;
private int currentPage = 1;
private int pageSize = 12;
private async Task GetUsersData()
{
isLoading = true;
response = await Client.GetFromJsonAsync<UsersResponse>($"api/Users?page={currentPage}&limit={pageSize}");
response.ThrowIfNull();
TotalPages = response.TotalPages;
isLoading = false;
}
2022-09-11 18:33:58 +02:00
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
{
await AuthService.LoginWithAuthToken();
}
2024-05-17 00:32:46 +02:00
if (AuthService.IsAdmin || !AuthService.LoginRequired)
{
await GetUsersData();
2024-05-17 00:32:46 +02:00
}
2022-09-11 18:33:58 +02:00
}
private async Task OnPageChange(int page)
{
currentPage = page;
await GetUsersData();
}
2022-09-11 18:33:58 +02:00
}