@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data.Repository
<span>@user.Email | </span>
<span>@user.Posts.Count Posts | </span>
<span>@user.Comments.Count Comments | </span>
<span>@user.SubmittedReports.Count Reports submitted | </span>
<span>@user.RecivedReports.Count Reports recived | </span>
<span> </span>
<select name="role" id="role" @bind="@selectedRole">
    <option value="User">User</option>
    <option value="Mod">Mod</option>
    <option value="Admin">Admin</option>
</select>
<a onclick="@updateRole()" href="javascript:void(0)" >Update Role</a>
<span> </span>
<span>@user.Role</span>
<br/>

@code {
    private string selectedRole;

    [Parameter]
    [Required]
    public UserData user { get; set; }

    protected override async Task OnInitializedAsync()
    {
        selectedRole = user.Role;
    }

    private async Task updateRole()
    {
        user.Role = selectedRole;
        await UsersRepository.updateUserAsync(user);
    }

}