@using WebApp.Models
@foreach (var student in
          Team.Students
              .OrderBy(e =>
                  e.EventRankings
                      .Find(er => er.EventDefinition == Team.Event)?.Rank ?? 10)
              .ThenBy(s => s.Grade + s.TsaYear))
{
    var eventRank = 
        student.EventRankings
            .Find(e => e.EventDefinition == Team.Event)?.Rank;
    var color = AppIcons.RankedEventColor(eventRank ?? 0);
    var captain = Team.Captain != null && Team.Captain.Equals(student);

    <MudPaper Class="d-inline-flex pa-2 mx-3 my-1" Style="@($"background:{color};")">
        @student.FirstName
        @if (captain)
        {
            <span> (Cpt)</span>
        }
    </MudPaper>
}

@code {
    [Parameter]
    public Team Team { get; set; }
}
