1
0
mirror of synced 2024-12-18 17:35:55 +01:00
TaikoLocalServer/TaikoWebUI/Components/Song/SongLeaderboardCard.razor.cs
2024-06-03 11:03:09 -04:00

40 lines
1.2 KiB
C#

namespace TaikoWebUI.Components.Song;
public partial class SongLeaderboardCard
{
private SongLeaderboardResponse? response = null;
[Parameter]
public int SongId { get; set; }
[Parameter]
public int Baid { get; set; }
[Parameter]
public Difficulty Difficulty { get; set; } = Difficulty.Hard;
private string SelectedDifficulty { get; set; } = "Hard";
private bool isLoading = true;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
response = await Client.GetFromJsonAsync<SongLeaderboardResponse>($"api/SongLeaderboard/{(uint)Baid}/{(uint)SongId}/{(uint)Difficulty}");
response.ThrowIfNull();
isLoading = false;
}
private async Task OnDifficultyChange(string difficulty)
{
isLoading = true;
SelectedDifficulty = difficulty;
Difficulty = Enum.Parse<Difficulty>(SelectedDifficulty);
response = await Client.GetFromJsonAsync<SongLeaderboardResponse>($"api/SongLeaderboard/{(uint)Baid}/{(uint)SongId}/{(uint)Difficulty}");
response.ThrowIfNull();
isLoading = false;
}
}