<table class="table table-hover table-condensed">
  <thead>
    <tr>
      <th>Mat</th>
      <th>Weight Classes (Max)</th>
      <th>Bracket Positions</th>
      <th>Rounds</th>
      <th><%= link_to ' New Mat Assignment Rule', new_tournament_mat_assignment_rule_path(@tournament), class: "fas fa-plus" %></th>
    </tr>
  </thead>
  <tbody>
    <% @mat_assignment_rules.each do |rule| %>
      <tr>
        <td><%= rule.mat.name %></td>
        <td>
          <% Array(rule.weight_classes).each_with_index do |weight_id, index| %>
            <% weight = @weights_by_id[weight_id.to_i] %>
            <%= weight ? weight.max : "N/A" %>
            <%= ", " unless index == Array(rule.weight_classes).size - 1 %>
          <% end %>
        </td>
        <td><%= Array(rule.bracket_positions).join(", ") %></td>
        <td><%= Array(rule.rounds).join(", ") %></td>
        <td>
          <%= link_to '', edit_tournament_mat_assignment_rule_path(@tournament, rule), class: "fas fa-edit" %>
          <%= link_to '', tournament_mat_assignment_rule_path(@tournament, rule), data: { turbo_method: :delete, turbo_confirm: "Are you sure?" }, class: "fas fa-trash-alt" %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
