<% if @tournaments.size > 0 %>
  <h3>My Tournaments</h3>
  <table class="table table-hover" id="tournamentList">
    <thead>
      <tr>
        <th>Name</th>
        <th>Date</th>
        <th><% if user_signed_in? %><%= link_to ' New Tournament', new_tournament_path, :class=>"fas fa-plus" %></th><% end %>
      </tr>
    </thead>

    <tbody>
      <% @tournaments.each do |tournament| %>
        <tr>
          <td><%= link_to "#{tournament.name}", tournament %></td>
          <td><%= tournament.date %></td>
            <% if can? :manage, tournament %>
            <td>
              <%= link_to '', edit_tournament_path(tournament), :class=>"fas fa-edit" %>
              <% if can? :destroy, tournament %>
                <%= link_to '', tournament, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{tournament.name}?" }, :class=>"fas fa-trash-alt" %>
              <% end %>
            </td>
            <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
  <br>
<% end %>
<% if @schools.size > 0 %>
  <h3>My Schools</h3>
  <table class="table table-hover" id="tournamentList">
    <thead>
      <tr>
        <th>Name</th>
        <th>Tournament Name</th>
        <th>Tournament Date</th>
      </tr>
    </thead>
  
    <tbody>
      <% @schools.each do |school| %>
        <tr>
          <td><%= link_to "#{school.name}", school %></td>
          <td><%= school.tournament.name %></td>
          <td><%= school.tournament.date %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
