<% unless @invitations.blank? %>
  <table summary="<%= t(".table.summary") %>">
    <caption><%= t(".table.caption") %></caption>
    <thead>
      <tr>
        <th scope="col"><%= t(".table.headings.token") %></th>
        <th scope="col"><%= t(".table.headings.sent_to") %></th>
        <th scope="col"><%= t(".table.headings.username") %></th>
        <th scope="col"><%= t(".table.headings.external_author") %></th>
        <th scope="col"><%= t(".table.headings.copy_link") %></th>
      </tr>
    </thead>
    <tbody>
      <% @invitations.each do |invitation| %>
        <tr>
          <td><%= link_to invitation.token, (invitation.creator.is_a?(User) ? [invitation.creator, invitation] : invitation) %></td>
          <td><%= invitation.invitee_email %></td>
          <td><%= invitee_link(invitation) %></td>
          <td>
            <%# TODO: internationalize this, including .to_sentence (and also do something about the parentheses) %>
            <%= invitation.external_author ? "#{invitation.external_author.email} (#{invitation.external_author.names.collect(&:name).delete_if { |name| name == invitation.external_author.email }
.join(',')})" : "" %>
          </td>
          <td>
            <% unless invitation.redeemed_at %>
            <% if invitation.external_author %>
              <%= link_to t(".table.actions.copy_and_use"), claim_path(invitation_token: invitation.token) %>
            <% else %>
              <%= link_to t(".table.actions.copy_and_use"), signup_path(invitation_token: invitation.token) %><% end %>
            <% end %>
          </td>
          <% if logged_in_as_admin? && invitation.redeemed_at.blank? %>
            <td>
              <%= link_to(t(".table.actions.delete"),
                    invitation, data: { confirm: t(".table.actions.delete_confirmation") }, method: :delete) %>
            </td>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
